SpringBoot 项目启动时设置 http 代理

SpringBoot 项目启动时设置 http 代理,第1张

  SpringBoot 项目打包成可执行 jar 文件 test-1.0.jar,在生产环境需要通过 http 代理服务器访问外部地址时,需要在项目启动时设置 http 代理,后台启动 jar 文件的脚本参考如下命令。

nohup java -Dhttps.proxySet=true -Dhttp.keepAlive=false -Dhttps.proxyHost=14.24.34.44 -Dhttps.proxyPort=10781  -Xms5g -Xmx5g -Xmn2g -Xss256k -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/logs/test_log/gctest.log -jar test-1.0.jar --spring.profiles.active=prod  >/dev/null 2>&1 &

部分参数释义如下:

  • -Dhttps.proxySet:设置为 true,说明需要 http 代理;
  • -Dhttp.keepAlive:设置为 false,说明设置 http 短连接;
  • -Dhttps.proxyHost:http 代理服务器地址;
  • -Dhttps.proxyPort:http 代理端口。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/738026.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存