【问题标题】:Mix SimpleClientHttpRequestFactory and HttpComponentsClientHttpRequestFactory混合 SimpleClientHttpRequestFactory 和 HttpComponentsClientHttpRequestFactory
【发布时间】:2023-07-09 02:21:02
【问题描述】:

我需要使用SimpleClientHttpRequestFactory 设置代理,并且需要使用HttpComponentsClientHttpRequestFactory 为Web 服务设置基本的autenticathion。

我正在使用 Spring restTemplate 服务,我需要混合 botch factorys

我该怎么做?

谢谢。

【问题讨论】:

    标签: spring proxy basic-authentication resttemplate


    【解决方案1】:

    我认为你正在尝试创建 HttpClient 来调用休息服务,你可以使用

    org.springframework.web.client.RestTemplate
    

    关于基本身份验证的详细信息在http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1/进行了解释

    【讨论】:

    • 我必须为服务设置用户和密码,而不是为代理设置。