2010-02-22 49 views
12

大家好我有错误,打破了我的体型没有理由,这里是错误消息:Maven的依赖log4j的错误

error: error reading 
/.m2/repository/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar; 
error in opening zip file error: error 
reading 
/.m2/repository/com/sun/jmx/jmxri/1.2.1/jmxri-1.2.1.jar; 
error in opening zip file 

我使用这种依赖关系:

<dependency> 
    <groupId>log4j</groupId> 
    <artifactId>log4j</artifactId> 
    <version>1.2.15</version> 
    <scope>provided</scope> 
</dependency> 

哪有我解决这个问题?

回答

23

你很可能并不需要jmxtools或jmxri,所以你也许可以从你的依赖其排除:

<dependency> 
    <groupId>log4j</groupId> 
    <artifactId>log4j</artifactId> 
    <version>1.2.15</version> 
    <scope>provided</scope> 
    <exclusions> 
     <exclusion> 
      <groupId>com.sun.jdmk</groupId> 
      <artifactId>jmxtools</artifactId> 
     </exclusion> 
     <exclusion> 
      <groupId>com.sun.jmx</groupId> 
      <artifactId>jmxri</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
+0

(+1)也为jmxri添加排除项。 – Bozho 2010-02-22 12:02:21

+0

正如Pascal所说,也为Java Mail和JMS添加排除。提供的范围?有时候更好地使用自己的日志库(就像帕斯卡所说的那样)从提供的环境之一。 – cetnar 2010-02-22 15:08:15

11

严重的是,对JMX,JMS这些依赖关系,Java邮件是荒谬的,不必处理排除一些日志记录使我无语。所以,我宁愿使用以前版本的log4j(1.2.14)或只是切换到logback

+0

有用的评论。我也只是决定切换到1.2.14。 – 2012-11-29 21:11:45

+0

他们可以使用“可选”的Maven依赖关系吗? – 2014-03-10 06:49:48