Maven依赖排除似乎不起作用 [英] Maven dependency exclusion doesn't seem to work
问题描述
我有一个Maven项目,具体取决于其他几个Maven项目.我在项目中使用Spring 3.1.1,而从属项目具有3.0.6.我试图在部署时排除Spring 3.0.6,因为两者都不可能.为此,我在POM中添加了一个明确的排除项,但是由于某些原因,当我启动Tomcat服务器时,我仍然在WEB-INF/lib
文件夹中看到旧版本的spring core jars.有人可以指出我要去哪里.这是我的pom.xml
:
I have a Maven project depending on couple other Maven projects. I am using Spring 3.1.1 in my project and dependent projects have 3.0.6. I am trying to exclude Spring 3.0.6 when deploying since having both isn't possible. I have added an explicit exclusion in my POM for that but for some reason I still see old version of spring core jars in the WEB-INF/lib
folder when I start the Tomcat server. Can someone point me out where I am going wrong. Here is my pom.xml
:
<project>
....
<properties>
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
</properties>
<dependency>
<groupId>com.test.abc</groupId>
<artifactId>abc</artifactId>
<version>1.0</version>
<type>war</type>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
<version>1.0-m2</version>
</dependency>
....
</project>
推荐答案
您的依赖类型是war,因此这里没有解决的问题. Maven将战争内容覆盖在您的项目上.
Your dependency type is war so there is no resolution happening here. Maven overlays the war contents over your project.
当战争发布到资源库时,工件将在WEB-INF lib文件夹中包含依赖库.覆盖期间,它不会将lib文件夹与任何静态资源区别开,除非您告诉它以不同的方式排除它.检查"overlay"属性
When the war is published to repository, the artifact will contain dependent libraries in WEB-INF lib folder. During overlay it does not treat lib folder any different from any static resource unless you tell it to exclude in different way.Check 'overlay' property here
这篇关于Maven依赖排除似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!