使用RestTemplate旋转代理

时间:2017-05-25 12:53:30

标签: java spring rest proxy

我在

之后的Spring应用程序的配置文件中定义了一个代理
    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();

        Proxy proxy= new Proxy(Proxy.Type.HTTP, new InetSocketAddress("my.host.com", 8080));
        requestFactory.setProxy(proxy);

        return new RestTemplate(requestFactory);
    }

有什么方法可以设置多个代理,这样当我访问自动装配的restTemplate时,每次使用另一个代理时我会使用不同的代理来实现requestFactory吗?

0 个答案:

没有答案