我正在处理一个 Maven 项目,其中我有 spring 框架依赖项版本 3.2.3.RELEASE,我必须将此项目导入到许多其他项目中,但在其中一些项目中我使用的是 spring 4。
仅当使用我的项目具有相同或更新版本的 spring 以及那些没有使用我的项目时,如何排除此依赖项(spring 3)?
您可以做的一件事是手动排除不需要的依赖项:
<dependency>
<groupId>com.your.project</groupId>
<artifactId>project-name</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-core</groupId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但这可能会变得相当冗长。
如果您详细说明问题描述可能会有所帮助,因为我不清楚您到底想解决或实现什么。
例如,如果您在 1.0 版本中包含一个依赖项 A,该依赖项 A 具有依赖项 B,然后您在 1.1 版本的 pom 中包含 B,则 Maven 将仅使用 1.1。我建议在这里阅读一下:https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Transitive_Dependencies
| 归档时间: |
|
| 查看次数: |
880 次 |
| 最近记录: |