我有一个包含多个模块的 Maven 项目。在 Eclipse(Juno,带有 m2e)中,它似乎编译得很好。但是当我在其中一个模块上进行 maven 安装时,构建会立即失败。
父pom:
<groupId>com.sw.system4</groupId>
<artifactId>system4-parent</artifactId>
<version>${system4.version}</version>
<packaging>pom</packaging>
<name>System 4 Parent Project</name>
<modules>
<module>system4-data</module>
...others...
</modules>
<properties>
<system4.version>0.0.1-SNAPSHOT</system4.version>
<spring.version>3.2.3.RELEASE</spring.version>
... others...
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<scope>runtime</scope>
</dependency>
... lots of others ...
</dependencies>
</dependencyManagement>
儿童绒球:
<parent>
<groupId>com.sw.system4</groupId>
<artifactId>system4-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>system4-data</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>runtime</scope>
</dependency>
... lots of others...
</dependencies>
当我构建时,我得到以下输出:
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.sw.system4:system4-data:0.0.1-SNAPSHOT (C:\work\eclips
e_workspaces\systemiv\system4-parent\system4-data\pom.xml) has 8 errors
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-cor
e:jar is missing. @ line 16, column 16
... others omitted for clarity ...
我不明白为什么它甚至不尝试编译。我已经尝试从父级和子级中删除运行时范围,这没有任何区别。请帮忙!
原文由 fancyplants 发布,翻译遵循 CC BY-SA 4.0 许可协议
我认为您可以尝试几件事:
清除通常位于 C:\Users\user.m2\repository 的 .m2 缓存。当我在 Maven 中工作时,我会说我经常这样做。尤其是在提交之前,这样我可以更有信心 CI 会运行。您不必每次都对文件夹进行核对,有时只需您的项目包和 .cache 文件夹就足够了。
将 relativePath 标记添加到您的父 pom 声明
看起来你的 pom 中有 8 个错误。在添加父 pom 和属性之前,我会尝试运行一些基本的编译。