作者rexhuang (BlueCancer)
看板java
标题[分享] 内网环境编译Maven专案,设定Proxy的步骤
时间Wed Mar 10 22:10:24 2021
一般公司电脑连外上网都会透过Proxy Server,编译Maven专案时需要特别设定Proxy并将
Maven网站的SSL凭证汇入到keystore,步骤如下。
(一)
设定Proxy:
settings.xml放在使用者目录的.m2资料夹
范例
https://tinyurl.com/6xkwmn3k
(二)
因为Maven站台使用https连线,需要透过浏览器汇出并将此SSL凭证汇入到keystore
参考
https://stackoverflow.com/questions/25911623/problems-using-maven-and-ssl-behind-proxy
Use a browser (I used IE) to go to
https://repo.maven.apache.org
Click on lock icon and choose "View Certificate"
Go to the "Details" tab and choose "Save to File"
Choose type "Base 64 X.509 (.CER)" and save it somewhere
Now open a command prompt and type (use your own paths):
指令
keytool -import -file C:\temp\mavenCert.cer -keystore C:\temp\mavenKeystore
(三)
指令加入以下属性参数(以执行Spring Boot专案为例)
mvn spring-boot:run -Djavax.net.ssl.trustStore=C:\temp\mavenKeystore
备注:
如果没有设定 -Djavax.net.ssl.trustStore=会有以下错误讯息
Maven sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
--
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.43.10.16 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/java/M.1615385428.A.7DC.html
1F:→ yoche2000: 感谢分享 03/14 15:40