如何告诉 Maven 使用哪个依赖项
How to say to Maven which dependency to use
现在我正在将遗留项目从 Spring 1 迁移到更大的版本(是的,我知道现在是 2017 年)。该项目有 1 个依赖项,其中包含很多 spring/ibatis 个依赖项。 ibatis 依赖项之一是版本 2.1.6 但迁移 spring 需要更大的版本 (2.3.4) 我将新的依赖项放在我的 pom 中但 maven 继续使用旧的。我知道在项目中有 2 个不同的版本不太好,我的主要目标是删除旧的大依赖项,但现在我想用新版本启动项目而不删除旧版本。
如何告诉 maven 使用哪个依赖项以及如何忽略另一个依赖项?如果这不可能,请告诉我如何轻松迁移。
谢谢。
在 pom 的 <dependency>
部分下添加 <exclusions>
标签。
More Details here
样本:
<project>
...
<dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
现在我正在将遗留项目从 Spring 1 迁移到更大的版本(是的,我知道现在是 2017 年)。该项目有 1 个依赖项,其中包含很多 spring/ibatis 个依赖项。 ibatis 依赖项之一是版本 2.1.6 但迁移 spring 需要更大的版本 (2.3.4) 我将新的依赖项放在我的 pom 中但 maven 继续使用旧的。我知道在项目中有 2 个不同的版本不太好,我的主要目标是删除旧的大依赖项,但现在我想用新版本启动项目而不删除旧版本。
如何告诉 maven 使用哪个依赖项以及如何忽略另一个依赖项?如果这不可能,请告诉我如何轻松迁移。
谢谢。
在 pom 的 <dependency>
部分下添加 <exclusions>
标签。
More Details here
样本:
<project>
...
<dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>