0

'Dependency1' 可传递地拉取'dependency2',我想在我的项目中管理'dependency2' 版本。

如果我在父 pom 的依赖管理部分中同时拥有“dependency1”和“dependency2”,而项目的只有“dependency1”子 pom,项目将引入哪个版本的“dependency2”?

像这样的东西:

父POM

<dependencyManagement>
  <dependencies>

        <dependency>
          <groupId> groupId </<groupId>
          <artifactId> artifact1 </artifactId>
          <version> version1 </version>
        </dependency>

        <dependency>
          <groupId> groupId </<groupId>
          <artifactId> artifact2 </artifactId>
          <version> version2 </version>
        </dependency>

  <dependencies>
<dependencyManagement>

儿童POM

<dependencies>
   <dependency>
       <groupId> groupId1 </<groupId>
          <artifactId> artifact1 </artifactId>
          <version> version1 </version>
       </dependency>
  <dependencies>
4

1 回答 1

1

您必须从重新定义的工件中排除传递依赖。

父 pom.xml:

<dependencyManagement>
  <dependencies>

        <dependency>
          <groupId> groupId </<groupId>
          <artifactId> artifact1 </artifactId>
          <version>artifact1</version>
        </dependency>

        <dependency>
          <groupId> groupId </<groupId>
          <artifactId> artifact2 </artifactId>
          <version> version2 </version>
        </dependency>

  <dependencies>
<dependencyManagement>

子 pom.xml:

<dependencies>
   <dependency>
       <groupId> groupId1 </<groupId>
          <artifactId> artifact1 </artifactId>
          <version> version1 </version>
          <exclusions>
            <exclude>
              <groupId>groupId</groupId>
              <artifactId>artifact2</artifactId>
            </exclude>
          </exclusions>
       </dependency>
  <dependencies>
于 2015-03-05T18:04:59.743 回答