0

我有这个没有依赖管理的 pom:

<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:gpt.ui:jar 的 'dependencies.dependency.version' 丢失。

那么,为什么我需要指定两倍的版本?这没有任何意义,我做错了什么?

4

1 回答 1

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>
于 2013-07-17T10:42:36.160 回答