admin管理员组文章数量:1567012
springboot中代理失败,下面的此配置要在springboot启动之前设置
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
@Configuration
public class JDKConfig {
@PostConstruct
public void httpsProxyConfig(){
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
}
}
使用
1、pom依赖
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.21</version>
</dependency>
2、实现
Authenticator.setDefault(
new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("账号", "密码".toCharArray());
}
}
);
/**
* springboot中下面jdk配置要在启动前配置
*/
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
HttpResponse execute = HttpRequest.get("https://www.baidu")
.setHttpProxy("代理的IP地址", 端口号)
.basicProxyAuth("账号", "密码")
.execute();
版权声明:本文标题:hutool的代理失败Unable to tunnel through proxy. Proxy returns “HTTP1.0 407 Proxy Authentication Required 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1725805247a1043946.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论