嗨,我在我的spring boot项目中遇到了proxy 407身份验证错误。我尝试了两种情况proxyhost和proxyport值正常工作,但用户名和密码无效?有人会遇到这种情况吗?在我的本地计算机上,当我提供端口和主机,但不提供用户名密码时,它会使我的本地用户正常工作,但我给用户名和密码的格式不对,看它的效果?我没有效果。另外,在服务器上我得到了407身份验证代理例外。如何在 Spring 启动传递代理用户名和密码?谢谢
我添加了jvm参数,但是proxyuser和proxypassword无效
-Dhttps.proxyHost=something -Dhttps.proxyPort=5555-Dhttps.proxyUser=xxx -Dhttps.proxyPassword=yyy
我还向MyRestTemplateBuilder添加了一些代理代码,但没有效果。
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);
1条答案
按热度按时间yv5phkfx1#
你应该试试this:-----
希望它能解决你的问题。