虽然“解决了”,但是总觉得为导入XML时使用代理,而去写个listener,有点怪怪的,于是深挖下去。
其实很简单的问题被我想复杂了,无非就是设置VM的运行时参数:
第一种方案:
在Ecplise中设置:
Run->Run Configurations->(x=)Argument:VM Arguments下设置:
-Dhttp.proxyHost=[代理IP地址] [空格] -Dhttp.proxyPort=[端口]
如果需要鉴权,则加上:
-Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword
第二种方案:
修改Tomcat的startup.bat,以windows的Tomcat6为例:
在“call "%EXECUTABLE%"”前增加:
set USE_PROXY_ARGS="-Dhttp.proxyHost=myHost -Dhttp.proxyPort=8080 -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword"
然后再call后增加这个参数就可以了:
call "%EXECUTABLE%" start %CMD_LINE_ARGS% %USE_PROXY_ARGS%
还可以在启动Tomcat运行脚本时增加参数,比较繁琐,原理和方案二一样,就不介绍了。