嗨,我在我的 Spring Boot 项目中遇到代理 407 身份验证错误。我在这些场景中尝试了两种场景,proxyHost 和 proxyPort 值正在工作,但用户名和密码无效?有人遇到这种情况吗?在我的本地机器上,当我提供端口和主机并且不提供用户名密码,它适用于我的本地用户和工作,但我以错误的格式提供用户名和密码以查看其效果?我没有效果。同样在服务器中,我得到了 407 身份验证代理异常。如何在 spring boot 中传递代理用户名和密码?谢谢
我添加了 jvm 参数但 proxyuser 和 proxyPassword 没有效果
-Dhttps.proxyHost=something -Dhttps.proxyPort=5555-Dhttps.proxyUser=xxx -Dhttps.proxyPassword=yyy
我还向 myresttemplate 构建器添加了一些代理代码,但它没有效果。
RestTemplate restTemplate=new RestTemplateBuilder()
.build();
int proxyPortNum =5555;
String proxyHost="something";
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPortNum), new UsernamePasswordCredentials("myname", "333"));
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.useSystemProperties();
clientBuilder.setProxy(new HttpHost(proxyHost, proxyPortNum));
clientBuilder.setDefaultCredentialsProvider(credsProvider);
clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
CloseableHttpClient client = clientBuilder.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(client);
restTemplate.setRequestFactory(factory);