启动tomcat设置http proxy

本文介绍如何通过设置JVM参数来为Tomcat应用配置HTTP代理,包括在启动脚本及Java代码中设置代理的方法。

通过设置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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值