我试图使用maven编译我的代码,得到以下错误,
环境
我正在使用azure服务器,并且使用构建管道Maven错误无法将工件org.apache.maven.plugins:maven-source-plugin:pom:3.0.1从/转到中心。
2021-02-26T11:43:14.4764714Z [ERROR] Plugin org.apache.maven.plugins:maven-source-plugin:3.0.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-source-plugin:jar:3.0.1: Could not transfer artifact org.apache.maven.plugins:maven-source-plugin:pom:3.0.1 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin/3.0.1/maven-source-plugin-3.0.1.pom ProxyInfo{host='12.3.4.59', userName='null', port=80, type='http', nonProxyHosts='null'}: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


发布于 2021-02-24 06:21:21
根据错误消息:
Transfer failed for https://repo.maven.apache.org/maven2...unable to find valid certification path to requested target它显示Maven正在尝试从位于https://repo.maven.apache.org/maven2的Maven中央存储库下载一个间接依赖项,这是一个安全HTTP服务器(HTTPS)。因此,问题可能来自您的证书本身或您的网络。
对于证书,尝试https://repo.maven.apache.org/maven2并下载证书,然后使用命令将其添加到仙人掌中:
keytool -import -alias example -keystore .\cacerts -file example.cer请尝试查看此线程"PKIX path building failed" and "unable to find valid certification path to requested target"的更多信息。
对于网络,请尝试访问您浏览器上的那个URL,并检查它是否可操作。如果您真的不能从浏览器中使用HTTPS访问Maven Central Repo,那么可能是因为您支持某种代理规则,从而阻止您下载服务器证书。
您可以设置settings.xml文件如下所示:
<proxies>
<proxy>
<active>true</active>
<protocol>https</protocol>
<host>MY_COMPANY_HOST</host>
<port>8080</port>
<username>MY_USERNAME</username>
<password>MY_PASSWORD</password>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>MY_COMPANY_HOST</host>
<port>8080</port>
<username>MY_USERNAME</username>
<password>MY_PASSWORD</password>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
</proxies>并查看线程Problems using Maven and SSL behind proxy以获得更多详细信息。
https://stackoverflow.com/questions/66333578
复制相似问题