我有下面的代码工作良好。虽然是在prod环境中,但我需要通过代理服务器读取json。怎样才能达到同样的效果?我可以看到一些通过代理使用https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/client/SimpleClientHttpRequestFactory.html的简单REST请求的谷歌示例,但不确定在这种情况下是否可以将其用于json阅读
JsonFactory jasonFactory = new JsonFactory();
URL productFeedFile = new URL("**URL");
JsonParser jsonParser = jasonFactory.createParser(productFeedFile);发布于 2020-07-30 20:04:37
嗯,我认为您的JsonFactory在幕后将URL转换为InputStream。如果你自己去做,你可以试试:
//Proxy instance, proxy ip = 10.0.0.1 with port 8080
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.0.0.1", 8080));
URLConnection conn = new URL(urlString).openConnection(proxy);
InputStream productFeedFileAsStream = conn.getInputStream();
JsonParser jsonParser = jasonFactory.createParser(productFeedFileAsStream);https://stackoverflow.com/questions/63172490
复制相似问题