依赖机制(覆盖传递版本)

时间:2011-03-22 18:56:27

标签: maven

我试图显式覆盖传递依赖版本,但似乎不起作用。

我在我的项目pom中有这个

<!-- use no-commons-logging -->
<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>99.0-does-not-exist</version>
</dependency>
<!-- no-commons-logging-api, if you need it -->
<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging-api</artifactId>
    <version>99.0-does-not-exist</version>
</dependency>

但是,第一个似乎没有覆盖传递依赖版本。我不确定为什么?

这是完整的POM http://pastebin.com/TBP0YTZs

这是依赖树 http://pastebin.com/VBdjiVcL

PS: a)这就是我想要做的 http://day-to-day-stuff.blogspot.com/2007/10/announcement-version-99-does-not-exist.html

1 个答案:

答案 0 :(得分:2)

实际上,有一种更清洁的方法可以一劳永逸地摆脱commons-logging

<dependency>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <version>1.1.1</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>jcl-over-slf4j</artifactId>
  <version>1.6.1</version>
</dependency>

基于:http://www.slf4j.org/faq.html#excludingJCL