C:\Users\z84405515\.jdks\ms-17.0.15\bin\java.exe -Dmaven.multiModuleProjectDirectory=C:\Users\z84405515\AppData\Local\Temp\archetype1tmp "-Dmaven.home=C:\Program Files\Maven" "-Dclassworlds.conf=C:\Program Files\Maven\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2024.3.2.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2024.3.2.2\lib\idea_rt.jar=63111:C:\Program Files\JetBrains\IntelliJ IDEA 2024.3.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Maven\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2024.3.2.2 -s "C:\Program Files\Maven\conf\settings.xml" -Dmaven.repo.local=C:\04_DevTools\maven_repo2 -DinteractiveMode=false -DgroupId=com.example -DartifactId=SpringBoot2 -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.1 org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate [INFO] Scanning for projects... Downloading: https://cmc.centralrepo.rnd.huawei.com/maven/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml Downloading: 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.377 s [INFO] Finished at: 2025-06-10T20:52:53+08:00 [INFO] Final Memory: 9M/48M [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: 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) -> [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
时间: 2025-06-10 09:44:02 浏览: 32
### 解决Maven构建失败问题:PKIX路径构建失败及插件解析错误
当Maven在构建项目时遇到`PluginResolutionException`或`PKIX path building failed`错误时,通常是因为SSL证书验证失败或远程仓库配置不正确。以下是针对此类问题的详细分析和解决方案:
#### 1. SSL证书验证失败
如果Maven无法通过SSL连接到远程仓库,可能会抛出以下错误:
```
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
```
这表明Maven无法验证目标仓库的SSL证书链[^1]。为解决此问题,可以尝试以下方法:
- **导入正确的SSL证书**
将目标仓库的SSL证书导入到Java的信任库中。可以通过以下命令完成:
```bash
keytool -importcert -file certificate.cer -keystore $JAVA_HOME/lib/security/cacerts
```
默认密码为`changeit`[^2]。
- **禁用SSL验证(仅用于测试环境)**
如果需要快速解决问题,可以通过设置以下参数来禁用SSL验证,但这种方法不适合生产环境:
```bash
mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
```
#### 2. 插件解析失败
当Maven无法从指定的远程仓库下载插件时,可能会抛出以下错误:
```
PluginResolutionException: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to nexus-aliyun
```
这可能是由于以下原因之一导致的:
- **仓库地址错误或不可达**
确保`settings.xml`文件中配置的仓库地址正确且可访问。例如,阿里云镜像仓库的配置如下:
```xml
<mirrors>
<mirror>
<id>aliyun</id>
<name>Aliyun Maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
```
- **网络问题**
如果网络连接不稳定,可能导致下载失败。可以尝试使用代理或切换网络环境[^3]。
- **强制更新依赖**
使用`-U`参数强制更新依赖项:
```bash
mvn clean install -U
```
#### 3. 配置本地仓库
如果本地仓库路径配置不正确,也可能导致插件解析失败。确保`settings.xml`中的`<localRepository>`标签指向有效的路径:
```xml
<localRepository>G:\MavenProject\NewRepository</localRepository>
```
#### 4. 检查Maven版本
某些旧版本的Maven可能不支持最新的SSL协议或加密算法。建议升级到最新版本的Maven以避免兼容性问题[^2]。
#### 5. 示例代码
以下是一个完整的Maven命令示例,包含禁用SSL验证和强制更新依赖的参数:
```bash
mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true -U
```
---
### 总结
通过上述方法,可以有效解决Maven构建过程中与SSL证书验证和插件解析相关的错误。具体措施包括导入正确的SSL证书、禁用SSL验证、检查仓库配置以及强制更新依赖等。
阅读全文
相关推荐



















