启动tomcat设置http proxy

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

通过设置jvm的proxyhost来实现设置tomcat中引用程序的代理

在catalina.bat/sh中设置set JAVA_FLAGS=-Dhttp.proxySet=true -Dhttp.proxyHost=proxyserver -Dhttp.proxyPort=8080, 然后在EXEC_JAVA部分加上这部分参数。

在代码中设置如下

Setting System Properties in Code

Add the following lines in your Java code so that JVM uses the proxy to make HTTP calls. This would, of course, require you to recompile your Java source. (The other methods do not require any recompilation):

System.getProperties().put("http.proxyHost","someProxyURL");
System.getProperties().put("http.proxyPort","someProxyPort");
System.getProperties().put("http.proxyUser","someUserName");
System.getProperties().put("http.proxyPassword","somePassword");

转载于:https://my.oschina.net/u/138995/blog/206805

你可能感兴趣的:(java,python)