[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ platform --- [INFO] Downloading from alimaven: http://maven.aliyun.com/repository/public/org/apache/maven/surefire/maven-surefire-common/2.22.2/maven-surefire-common-2.22.2.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.424 s [INFO] Finished at: 2024-07-07T15:48:00+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project platform: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.22.2 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:2.22.2 -> org.apache.maven.surefire:maven-surefire-common:jar:2.22.2: Failed to read artifact descriptor for org.apache.maven.surefire:maven-surefire-common:jar:2.22.2: Could not transfer artifact org.apache.maven.surefire:maven-surefire-common:pom:2.22.2 from/to alimaven (http://maven.aliyun.com/repository/public): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
解决办法:
1、导入证书:浏览器访问
http://maven.aliyun.com/repository/public 导出证书。
并将其导入到本地的 Java 密钥库中。这样可以让 Maven 信任证书并建立安全连接。你可以使用随 Java 开发工具包 (JDK) 提供的 keytool
命令行工具导入证书。以下是示例命令:
keytool -import -alias my-cert -keystore <密钥库路径> -file <证书路径>
keytool -import -alias my-cert -keystore C:\Java8\jdk1.8.0_131\jre\lib\security\cacerts -file C:\Users\TOP\Desktop\xxx\xxx.aliyun.com
2、在 Maven 设置中显式信任证书:在你的 settings.xml
文件中添加以下配置,以显式信任远程仓库的证书:
<settings> ... <profiles> <profile> <id>trust-repository-certificate</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>my-repository</id> <url>https://example.com/repository</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> <pluginSnapshots> <enabled>true</enabled> </pluginSnapshots> <trustCertificates>true</trustCertificates> <certificatePath>/证书路径</certificatePath> </repository> </repositories> </profile> </profiles> ... </settings>
将 my-repository
、https://example.com/repository
和 /证书路径
替换为你的仓库和证书的相应值。
3、禁用证书验证(不推荐):作为最后的手段,你可以在 Maven 设置中禁用证书验证。然而,这不推荐使用,因为它会降低安全性并暴露给潜在的安全风险。要禁用证书验证,在 settings.xml
文件中添加以下配置:
<settings> ... <ssl> <trustAll>true</trustAll> </ssl> ... </settings>
过将 <trustAll>
设置为 true
,Maven 将信任所有证书,包括自签名或无效证书。再次强调,这在生产环境中不推荐使用。
标签:requested,证书,surefire,maven,apache,valid,报错,2.22,org From: https://www.cnblogs.com/digdeep/p/18288648