我有一个父母pom和一个整合pom:
集成pom
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
父pom
<modules>
<module>../example-business</module>
<module>../example-integration</module>
<module>../example-model</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
现在,当我在父进程上进行全新安装时,出现以下错误:
[INFO] Scanning for projects...
Downloading: http://www.example.com/content/groups/mirror/com/example/example-parent/0.0.1-SNAPSHOT/maven-metadata.xml
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.example:example-integration:0.0.1-SNAPSHOT (D:\dev\workspaces\example-git\example\example-integration\pom.xml) has 3 errors
[ERROR] 'dependencies.dependency.version' for org.json:json:jar is missing. @ line 22, column 15
[ERROR] 'dependencies.dependency.version' for commons-httpclient:commons-httpclient:jar is missing. @ line 27, column 15
[ERROR] 'dependencies.dependency.version' for com.example:example-model:jar is missing. @ line 32, column 15
但是当我看一下集成pom的Effective POM时,会有写的版本 那么为什么我不能建立呢?
编辑:
以下是 EFFECTIVE POM 视图的片段:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-business</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-business</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
答案 0 :(得分:8)
问题在于您的项目结构以及如何在子poms中定义parent
。
您的子模块实际上位于父pom所在的文件夹中,而不是在同一级别(从<module>../example-business</module>
判断)。当maven尝试构建子模块时,它无法找到父pom,因为它在maven存储库中不可用(它当前正在构建它以便它尚未上传)。
要解决此问题,您只需更改子poms中的parent
定义,即可定义父pom位置的真实relativePath
,以便maven可以找到它。因此,将其更改为以下内容:
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../name-of-folder-containing-parent-pom</relativePath>
</parent>
显然,您需要将name-of-folder-containing-parent-pom
更改为文件夹。
答案 1 :(得分:0)
检查为什么本地无法解决父级依赖关系。 您可能在位于c:Users / name / .m2的settings.xml中缺少某些内容 检查凭据是否正确,并且是否添加了所有人工链接,以防它们不是公开的。
答案 2 :(得分:-1)
我也有类似的问题,可以通过在下面添加错过的结束标签来解决
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jexl</artifactId>
<version>2.1.1</version>
<dependency>
同样解决如下:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jexl</artifactId>
<version>2.1.1</version>
</dependency>