maven的全局去除依赖

来源:互联网 发布:直销双轨软件 编辑:程序博客网 时间:2024/05/21 15:46

maven的全局去除依赖


我们在maven中有时候希望将某个依赖包彻底去除


如我们的系统使用的是spring3.1.2, 但是依赖的二方包中, 总是或多或少依赖了spring2.5.6, 希望有个方法, 能全局去除掉


Java代码  收藏代码
  1. <!-- globally exclusion -->  
  2. <dependency>  
  3.     <groupId>org.springframework</groupId>  
  4.     <artifactId>spring</artifactId>  
  5.     <version>2.5.6.SEC03</version>  
  6.     <scope>provided</scope>  
  7. </dependency>  


以上方式, 有个弊端, 就是eclipse中, 还是会依赖, 且容易用混


有三个方案(建议使用第三种)
Xml代码  收藏代码
  1. <dependency>  
  2.     <groupId>org.springframework</groupId>  
  3.     <artifactId>spring</artifactId>  
  4.     <version>99.0-does-not-exist</version>  
  5.     <scope>provided</scope>  
  6. </dependency>  


Xml代码  收藏代码
  1. <dependency>  
  2.     <groupId>org.springframework</groupId>  
  3.     <artifactId>spring</artifactId>  
  4.     <version>2.5.6</version>  
  5.     <scope>system</scope>  
  6.     <systemPath>${basedir}/lib/empty.jar</systemPath>  
  7. </dependency>  


Xml代码  收藏代码
  1. <plugin>  
  2.     <artifactId>maven-eclipse-plugin</artifactId>  
  3.     <configuration>  
  4.         <downloadSources>true</downloadSources>  
  5.         <downloadJavadocs>true</downloadJavadocs>  
  6.         <classpathContainers>  
  7.             <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>  
  8.         </classpathContainers>  
  9.         <excludes>  
  10.             <exclude>org.springframework:spring</exclude>  
  11.         </excludes>  
  12.     </configuration>  
  13. </plugin>  
0 0
原创粉丝点击