为tomcat 8中部署的Java应用程序设置代理
我正在Tomcat8.5中部署应用程序。这个tomcat运行在一个代理之后。如果我使用eclipse,应用程序可以正常运行,但不能在Tomcat中运行。我已经看到,如果使用web浏览器进行身份验证,应用程序运行正常,而身份验证仍然存在。一旦过期,我需要再次提供凭据 我试图通过代码提供这些信息,并在catalina.bat中添加了以下行: http.proxyHost=proxy.myproxy.es http.proxyPort=8080 http.proxyUser=USERNAME http.proxyPassword=PWD为tomcat 8中部署的Java应用程序设置代理,java,tomcat,proxy,Java,Tomcat,Proxy,我正在Tomcat8.5中部署应用程序。这个tomcat运行在一个代理之后。如果我使用eclipse,应用程序可以正常运行,但不能在Tomcat中运行。我已经看到,如果使用web浏览器进行身份验证,应用程序运行正常,而身份验证仍然存在。一旦过期,我需要再次提供凭据 我试图通过代码提供这些信息,并在catalina.bat中添加了以下行: http.proxyHost=proxy.myproxy.es http.proxyPort=8080 http.proxyUser=USERNAME http
System.setProperty(“http.proxyHost”,代理服务器);
setProperty(“http.proxyPort”,PROXY_PORT.toString());
System.setProperty(“https.proxyHost”,代理服务器);
System.setProperty(“https.proxyPort”,PROXY_PORT.toString());
System.setProperty(“http.proxyUser”,PROXY\u USER);
System.setProperty(“http.proxyPassword”,PROXY\u密码);
System.setProperty(“http.proxySet”、“true”);
//奥特提卡莫斯酒店
setDefault(新验证器(){
@凌驾
受保护的密码身份验证getPasswordAuthentication(){
if(getRequestorType()==RequestorType.PROXY){
字符串prot=getRequestingProtocol().toLowerCase();
字符串host=System.getProperty(prot+“.proxyHost”,代理服务器);
String port=System.getProperty(prot+“.proxyPort”,PROXY_port.toString());
字符串user=System.getProperty(prot+“.proxyUser”,PROXY\u user);
字符串密码=System.getProperty(prot+“.proxyPassword”,PROXY\u密码);
if(getRequestingHost().equalsIgnoreCase(主机)){
if(Integer.parseInt(port)==getRequestingPort()){
返回新密码身份验证(用户,password.tocharray());
}
}
}
返回null;
}
});
我需要此身份验证自动运行
编辑:此代理应由第三方类使用。如果我创建一个到一个随机URL(如google.com)的新连接,然后使用第三方类发出请求,它工作正常,因此我假设它没有使用Authenticator.setDefault。知道发生了什么吗?最后,第三方类有一个bug。
关闭您的问题是什么?如何在不通过浏览器提供凭据的情况下使其工作。为什么tomcat不使用setProperty值?