我不依赖于依赖管理:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.domini</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.logica</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
在我的耳模块中,我想引用这种依赖关系,如:
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.domini</artifactId>
<!-- <version>${project.version}</version>-->
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ejb</artifactId>
<!-- <type>ejb</type>-->
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.logica</artifactId>
<!-- <version>${project.version}</version>-->
<!-- <type>jar</type>-->
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<!-- <version>${project.version}</version>-->
<!-- <type>war</type>-->
</dependency>
</dependencies>
但是maven告诉我这个错误: 项目构建错误:cat.base.gpt的'dependencies.dependency.version':gpt.ui:jar丢失了。
那么,为什么我需要指定两次版本?这没有任何意义,我做错了什么?
答案 0 :(得分:0)
问题是您通过dependencyManagement定义
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
但在您的依赖项中,您定义了以下内容:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<!-- <version>${project.version}</version>-->
<!-- <type>war</type>-->
</dependency>
这意味着没有定义类型,并且在maven措辞意味着类型被假定为默认值: jar 所以你需要将你的依赖关系改为:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<type>war</type>
</dependency>