创建Maven子项目时出现“Unable to read parent POM”的问题

本文介绍了一种解决Maven子项目中出现的“Unable to read parent POM”错误的方法。作者最初遇到该问题时尝试了多种解决方式未果,最终通过删除主项目的pom.xml文件中的中文字符解决了问题。

    今天创建Maven子项目时出现了如下问题:“Unable to read parent POM“。

    怎么折腾都不行。后来试着把主工程的pom.xml文件中的所有中文都去掉就可以了。可以后即使主工程的pom.xml文件里有中文,发现也没问题。

[ERROR] [ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM for com.exmaple:graalvmtest:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.tplink.smb:solution-components-cache:pom:1.4.11 (present, but unavailabl e): Could not transfer artifact com.tplink.smb:solution-components-cache:pom:1.4.11 from/to aliyunmaven (https://maven.aliyun.com/repository/public): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at wrong local POM @ line 5, column 13 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project com.exmaple:graalvmtest:0.0.1-SNAPSHOT (D:\tplearning_train_project\TESTPROJECT\graalvmtest\pom.xml) has 1 error [ERROR] Non-resolvable parent POM for com.exmaple:graalvmtest:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.tplink.smb:solution-components-cache:pom:1.4.11 (present, but unavai lable): Could not transfer artifact com.tplink.smb:solution-components-cache:pom:1.4.11 from/to aliyunmaven (https://maven.aliyun.com/repository/public): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and 'parent.relativePath' points at wrong local POM @ line 5, column 13 -> [Help 2] [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. 我在运行mvn -Pnative clean native:compile报错
最新发布
09-27
使用命令行创建多模块项目 创建父项目: 使用以下命令创建父项目: Bash mvn archetype:generate \ -DgroupId=com.example \ -DartifactId=my-multi-module \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false 删除父项目的 src 目录: Bash rm -rf my-multi-module/src 创建子模块: 进入父项目目录,并创建子模块: Bash cd my-multi-module mvn archetype:generate \ -DgroupId=com.example \ -DartifactId=module1 \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false Bash mvn archetype:generate \ -DgroupId=com.example \ -DartifactId=module2 \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false 修改父项目的 pom.xml 文件,添加 <modules> 配置: XML <modules> <module>module1</module> <module>module2</module> </modules> 配置父 POM 和子模块 POM: 父项目的 pom.xml 文件中定义 <dependencyManagement> 和 <pluginManagement>。 子模块的 pom.xml 文件中添加 <parent> 配置,继承父项目的公共依赖和插件。 验证模块是否成功继承 检查子模块的 pom.xml 文件: 确保子模块中正确声明了 <parent> 配置。 子模块的 pom.xml 文件应包含父 POM 中定义的依赖和插件。 使用 Maven 命令验证构建: 在父项目目录下运行以下命令,验证整个项目的构建是否成功: Bash mvn clean install 检查依赖关系: 使用 mvn dependency:tree 命令查看子模块的依赖树,确保所有依赖都已正确解析。 在该步骤中的创建子模块我报错了:[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.855 s [INFO] Finished at: 2025-07-31T14:13:34+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.4.0:generate (default-cli) on project my-multi-module: Unable to add module to the current project as it is not of packaging type 'pom' -> [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/MojoExecutionException
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值