解决 Maven 报错 Non-resolvable parent POM ... was cached in the local repository, resolution will not be

本文记录了一位开发者在重构项目时遇到的Maven报错问题,错误信息涉及parent POM无法解析。经过排查,问题出在使用了properties中的元素作为Maven坐标,而Maven在解析坐标时并未识别。解决方案是避免在坐标中使用properties,确保parent POM坐标明确。此问题可能导致项目构建失败,提醒开发者注意POM文件的正确配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决 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 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 坐标,然后继承才会发生。终于知道真相的笔者眼泪掉下来。希望读者引以为戒。

### 关于面包板电源模块 MB102 的 USB 供电规格及兼容性 #### 1. **MB102 基本功能** 面包板电源模块 MB102 是一种常见的实验工具,主要用于为基于面包板的小型电子项目提供稳定的电压输出。它通常具有两路独立的稳压输出:一路为 5V 和另一路可调电压(一般范围为 3V 至 12V)。这种设计使得它可以满足多种芯片和传感器的不同工作电压需求。 #### 2. **USB 供电方式** MB102 支持通过 USB 接口供电,输入电压通常是标准的 5V DC[^1]。由于其内部集成了 LM7805 稳压器以及可调节电位器控制的直流-直流变换电路,因此即使输入来自电脑或其他低功率 USB 设备,也能稳定地向负载供应电力。不过需要注意的是,如果项目的功耗较高,则可能超出某些 USB 端口的最大电流能力(一般是 500mA),从而引起不稳定现象或者保护机制启动断开连接的情况发生。 #### 3. **兼容性分析** 该型号广泛适用于各种微控制器单元 (MCU),特别是那些像 Wemos D1 R32 这样可以通过杜邦线轻松接入并共享相同逻辑级别的系统[^2]。另外,在提到 Arduino Uno 板时也表明了良好的互操作性,因为两者均采用相似的标准接口定义与电气特性参数设置[^4]: - 对于需要 3.3V 工作环境下的组件来说,只需调整好对应跳线帽位置即可实现精准匹配; - 当涉及到更多外围扩展应用场合下,例如带有多重模拟信号采集任务的情形里,利用 MB102 提供干净无干扰的基础能源供给就显得尤为重要了[^3]。 综上所述,对于打算构建以单片机为核心的原型验证平台而言,选用具备良好声誉记录且易于获取配件支持服务链路上下游资源丰富的品牌产品——如这里讨论过的这款特定类型的配电装置不失为明智之举之一。 ```python # 示例 Python 代码展示如何检测硬件状态 import machine pin = machine.Pin(2, machine.Pin.IN) if pin.value() == 1: print("Power supply is stable.") else: print("Check your connections and power source.") ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值