相关文章推荐
小胡子的薯片  ·  CURLOPT_CONNECTTIMEOUT ...·  3 月前    · 
温柔的烤红薯  ·  oracle to_date format ...·  1 年前    · 
大气的针织衫  ·  Python ...·  1 年前    · 

笔者使用 IntelliJ IDEA 对以前的项目作重构时,发现一个匪夷所思的问题:明明使用 IntelliJ IDEA 运行项目时,项目正常运行,但使用 Maven 命令进行 clean、compile、install 时,对项目中的每一个模块,均发生如下的报错。

笔者报错时的运行环境:

JDK 13.0.2

Maven 3.6.3

IntelliJ IDEA 2020.1.2 (Ultimate Edition)

这个报错的信息如下:

"C:\Program Files\Java\jdk-13.0.2\bin\java.exe" -Dmaven.multiModuleProjectDirectory=XXX -Xms128m -Xmx512m "-Dmaven.home=XXX\plugins\maven\lib\maven3" "-Dclassworlds.conf=XXX\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=XXX\plugins\maven\lib\maven-event-listener.jar" "-javaagent:XXX\lib\idea_rt.jar=25353:XXX\bin" -Dfile.encoding=UTF-8 -classpath "XXX\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;XXX\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.versionXXXorg.apache.maven.plugins:maven-clean-plugin:2.5:clean
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'artifactId' contains an expression but should be a constant. @ line 17, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.junit.jupiter:junit-jupiter:jar -> duplicate declaration of version (?) @ line 35, column 21
[WARNING] 'artifactId' contains an expression but should be a constant. @ XXX:${project_artifactId}:${project_version}, XXX\pom.xml, line 13, column 17
[WARNING] 'version' contains an expression but should be a constant. @ XXX:${project_artifactId}:${project_version}, XXX\pom.xml, line 14, column 14
[WARNING] 'parent.relativePath' of POM XXX:${project_artifactId}:XXX (XXX\XXX\pom.xml) points at XXX:${project_artifactId} instead of XXX:XXX-project, please verify your project structure @ line 9, column 13
[FATAL] Non-resolvable parent POM for XXX:${project_artifactId}:XXX: Failure to find XXX:XXX-project:pom:XXX in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 9, column 13
[WARNING] 'artifactId' contains an expression but should be a constant. @ line 17, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.junit.jupiter:junit-jupiter:jar -> duplicate declaration of version (?) @ line 29, column 21
[WARNING] 'artifactId' contains an expression but should be a constant. @ XXX:${project_artifactId}:${project_version}, XXX\pom.xml, line 13, column 17
[WARNING] 'version' contains an expression but should be a constant. @ XXX:${project_artifactId}:${project_version}, XXX\pom.xml, line 14, column 14
[WARNING] 'parent.relativePath' of POM XXX:${project_artifactId}:XXX (XXX\XXX-exception\pom.xml) points at XXX:${project_artifactId} instead of XXX:XXX-project, please verify your project structure @ line 9, column 13
[FATAL] Non-resolvable parent POM for XXX:${project_artifactId}:XXX: Failure to find XXX:XXX-project:pom:XXX in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 9, column 13
[WARNING] 'artifactId' contains an expression but should be a constant. @ XXX:${project_artifactId}:${project_version}, XXX\pom.xml, line 13, column 17
[WARNING] 'version' contains an expression but should be a constant. @ XXX:${project_artifactId}:${project_version}, XXX\pom.xml, line 14, column 14
[ERROR] The build could not read 2 projects -> [Help 1]
[ERROR]   
[ERROR]   The project XXX:${project_artifactId}:XXX (XXX\XXX\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for XXX:${project_artifactId}:XXX: Failure to find XXX:XXX-project:pom:XXX in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 9, column 13 -> [Help 2]
[ERROR]   
[ERROR]   The project XXX:${project_artifactId}:XXX (XXX\XXX-exception\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for XXX:${project_artifactId}:XXX: Failure to find XXX:XXX-project:pom:XXX in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 9, 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.
[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/UnresolvableModelException

  在笔者不断地新建工程,不断地隔离模块的努力下,终于发现了原因所在。(当然,每个遇到这个问题的读者可能原因不同,这里仅供参考。)

  为了偷懒,笔者编写了一个愚蠢的代码。这段代码类似如下:

    <properties>
        <project_artifactId>demo-project</project_artifactId>
        <project_version>1.2</project_version>
    </properties>
    <groupId>org.demo</groupId>
    <artifactId>${project_artifactId}</artifactId>
    <version>${project_version}</version>
    <packaging>pom</packaging>
    <name>{project_artifactId}</name>

  上述代码的问题在于,对 Maven 项目的坐标使用了 <properties/...> 中的元素来代替。但实际上,<properties/...> 应该在依赖(<dependencies/...>)中使用。Maven 并未在坐标中识别出 <properties/...>,因为坐标解析发生在解析 <properties/...> 之前。同样地,对于子 pom,虽然父 pom 中的 <properties/...> 可以被子 pom 继承,不过在子 pom 中的 <parent/...> 坐标里同样不能解析父 pom 中的 <properties/...>,因为必须要先明确地指定它的父 pom 坐标,然后继承才会发生。终于知道真相的笔者眼泪掉下来。希望读者引以为戒。

解决 Maven 报错 Non-resolvable parent POM ... was cached in the local repository, resolution will not be 解决 Maven 报错 Non-resolvable parent POM ... was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM  笔者使用 IntelliJ ID. 从SVN下载项目后,运行 maven update project,发现pom.xml还有很多的jar包没有下载,报错信息如下所示: Maven:resolution will not be reattempted until the update interval of central has elapsed or updates are forced 问题原因... 一般按照clean-compile-package-install打包命令执行后,检查jar包是否打包成功,然后问题基本都解决了 {如果还是有问题,加我微信:444520455,备注:开发者}
文章目录原因解决办法原理 Maven complaining about parent relative path 刚来新公司,工作的时候leader 让导入了一个maven 聚合的项目。 需求是从maven聚合项目,中独立一个服务出来。 类似上图独立 eurekaserver 项目成一个独立的项目,方便部署。 报错信息: [FATAL] Non-resolvable parent POM for com.alibaba:********:[unknown-version]: Could not fin
解决IntelliJ IDEA报错Error:Cannot determine path to ‘tools.jar‘ library for 17 (C:\Program Files\Java\jd 75621 解决IntelliJ IDEA报错Failed to read candidate component class: file [ ]; nested exception is org. 感谢你,我用的也是JDK17,看了你的评论把Spring改成6.0.6也正常运行了表情包 解决IntelliJ IDEA报错:调用方法[manageApp]时发生异常java.lang.IllegalStateException: 启动子级时出错 Embraceべ: 还有一种可能就是webservlet路径没有加/ 如何在 Java 中调用 MATLAB 代码 Timmytim: 我在导入jar以后,遇到了“java.lang.UnsatisfiedLinkError: Failed to find the required library libmwmclmcrrt.so.9.9 on java.library.path. This library is typically installed along with MATLAB or the MATLAB Runtime. Its absence may indicate an issue with that installation or the current path configuration, or a mismatch with the architecture of the Java interpreter on the path. MATLAB Runtime version this component is attempting to use: 9.9. Java interpreter architecture: glnxa64.” 这个问题,不知道作者有没有遇到呀,环境变量也配置了,不知道问题出在哪了