[INFO] Scanning for projects... Downloading from dg-artifact: https://cmc.centralrepo.rnd.huawei.com/maven/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml Downloading from artifact-plugins: https://dgg.maven.repo.cmc.tools.huawei.com/artifactory/BPIT-public-maven/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml [WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to artifact-plugins (https://dgg.maven.repo.cmc.tools.huawei.com/artifactory/BPIT-public-maven/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target [WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to dg-artifact (https://cmc.centralrepo.rnd.huawei.com/maven/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.365 s [INFO] Finished at: 2025-06-10T20:31:09+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: [ERROR] Failed to resolve version for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local (C:\04_DevTools\maven_repo2) [ERROR] -> [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
时间: 2025-06-10 13:44:11 浏览: 13
### Maven maven-archetype-plugin PKIX path building failed 问题解决方案
在使用Maven插件 `maven-archetype-plugin` 时,如果遇到证书路径错误(PKIX path building failed)和依赖无法解析的问题,通常是因为SSL证书验证失败导致的。以下是解决该问题的详细方法:
#### 方法一:忽略SSL证书验证
可以通过在Maven运行参数中添加以下选项来忽略SSL证书验证[^3]:
```bash
-Dmaven.wagon.http.ssl.insecure=true \
-Dmaven.wagon.http.ssl.allowall=true \
-Dmaven.wagon.http.ssl.ignore.validity.dates=true
```
将这些参数添加到IDEA的Maven设置中(例如,在VIM Options位置),或者直接在命令行运行Maven命令时附加这些参数。
#### 方法二:导入正确的SSL证书
如果忽略SSL证书验证不是理想的选择,可以尝试导入正确的SSL证书到Java的信任库中。具体步骤如下:
1. 下载目标仓库的SSL证书(例如从浏览器中导出)。
2. 使用以下命令将证书导入到Java的信任库中:
```bash
keytool -import -trustcacerts -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit -alias <证书别名> -file <证书文件路径>
```
其中 `<证书别名>` 是为证书指定的名称,`<证书文件路径>` 是下载的SSL证书文件路径[^1]。
#### 方法三:更换可信的Maven镜像源
如果当前使用的Maven镜像源存在证书问题,可以尝试更换为其他可信的镜像源。例如,将 `settings.xml` 文件中的镜像配置更改为阿里云的HTTPS镜像源:
```xml
<mirror>
<id>aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Aliyun Maven</name>
<url>https://maven.aliyun.com/repository/public</url>
</url>
```
确保使用的是HTTPS协议,以避免SSL证书相关问题[^2]。
#### 方法四:升级Maven版本
某些旧版本的Maven可能存在SSL兼容性问题。建议升级到最新版本的Maven,以获得更好的SSL支持和安全性改进[^4]。
#### 示例代码:通过命令行运行Maven并忽略SSL验证
```bash
mvn archetype:generate \
-Dmaven.wagon.http.ssl.insecure=true \
-Dmaven.wagon.http.ssl.allowall=true \
-Dmaven.wagon.http.ssl.ignore.validity.dates=true
```
---
###
阅读全文
相关推荐



















