Quarkus项目创建构建失败求助(JDK11+Maven3.9.9)
问题:Quarkus项目创建时Maven依赖解析失败
环境信息
- JDK版本:11
- Maven版本:3.9.9
执行的创建命令
mvn -U io.quarkus:quarkus-maven-plugin:create -DprojectGroupId=org.agoncal.quarkus.starting -DprojectArtifactId=rest-book -DclassName="org.agoncal.quarkus.starting.BookResource" -Dpath="/api/books" -Dextensions="resteasy-jsonb"
错误信息
[ERROR] [ERROR] Some problems were encountered while processing the POMs: [ERROR] Unresolveable build extension: Plugin io.quarkus.platform:quarkus-maven-plugin:3.14.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for io.quarkus.platform:quarkus-maven-plugin:jar:3.14.4 @ [ERROR] Non-resolvable import POM: The following artifacts could not be resolved: io.quarkus.platform:quarkus-bom:pom:3.14.4 (absent): Could not transfer artifact io.quarkus.platform:quarkus-bom:pom:3.14.4 from/to central (https://repo1.maven.org/maven2): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target @ line 22, column 25 [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest-jsonb:jar is missing. @ line 33, column 21 [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-arc:jar is missing. @ line 37, column 21 [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest:jar is missing. @ line 41, column 21 [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-junit5:jar is missing. @ line 45, column 21 [ERROR] 'dependencies.dependency.version' for io.rest-assured:rest-assured:jar is missing. @ line 50, column 21 [ERROR] [ERROR] The project org.agoncal.quarkus.starting:rest-book:1.0.0-SNAPSHOT (C:\Users\223099871.HCAD\Downloads\rest-book (1)\rest-book\pom.xml) has 7 errors [ERROR] Unresolveable build extension: Plugin io.quarkus.platform:quarkus-maven-plugin:3.14.4 or one of its dependencies could not be resolved: [ERROR] Failed to read artifact descriptor for io.quarkus.platform:quarkus-maven-plugin:jar:3.14.4 [ERROR] -> [Help 2] [ERROR] Non-resolvable import POM: The following artifacts could not be resolved: io.quarkus.platform:quarkus-bom:pom:3.14.4 (absent): Could not transfer artifact io.quarkus.platform:quarkus-bom:pom:3.14.4 from/to central (https://repo1.maven.org/maven2): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target @ line 22, column 25 -> [Help 3] [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest-jsonb:jar is missing. @ line 33, column 21 [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-arc:jar is missing. @ line 37, column 21 [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest:jar is missing. @ line 41, column 21 [ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-junit5:jar is missing. @ line 45, column 21 [ERROR] 'dependencies.dependency.version' for io.rest-assured:rest-assured:jar is missing. @ line 50, column 21 [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/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException [ERROR] [Help 3] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
已尝试的方法
- 使用curl测试网络连接
- 配置Jbang尝试创建项目,问题依旧
解决方案
1. 解决PKIX证书验证问题(核心原因)
错误中的PKIX path building failed是根本问题,说明Maven无法验证Maven中央仓库的SSL证书,可通过以下方式修复:
- 导入中央仓库证书到JDK信任库:
- 浏览器访问Maven中央仓库,导出网站SSL证书(格式选DER或PEM)
- 用JDK自带
keytool命令导入证书:
注:默认信任库密码为keytool -import -trustcacerts -alias maven-central -file 证书文件路径 -keystore $JAVA_HOME/jre/lib/security/cacertschangeit,Windows系统需替换$JAVA_HOME为实际JDK安装路径(如C:\Program Files\Java\jdk-11.x.x)
- 配置Maven代理(企业网络环境):
在settings.xml(路径:~/.m2/settings.xml或MAVEN_HOME/conf/settings.xml)中添加代理配置:<proxies> <proxy> <id>company-proxy</id> <active>true</active> <protocol>https</protocol> <host>代理地址</host> <port>代理端口</port> <!-- 如需认证,添加以下两行 --> <!-- <username>代理用户名</username> --> <!-- <password>代理密码</password> --> <nonProxyHosts>localhost,127.0.0.1</nonProxyHosts> </proxy> </proxies>
2. 修复POM依赖版本问题
证书问题解决后,依赖版本缺失的问题会自动修复(Quarkus BOM会统一管理版本)。若仍有问题,可手动在pom.xml中确认BOM导入:
<dependencyManagement> <dependencies> <dependency> <groupId>io.quarkus.platform</groupId> <artifactId>quarkus-bom</artifactId> <version>3.14.4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
3. 重新执行创建命令
配置完成后,先清理本地Maven缓存,再重新执行项目创建命令:
mvn clean install -U
内容的提问来源于stack exchange,提问作者Ishani
相关产品推荐
相关产品推荐

