2014-03-28 35 views
1

當我加入java.mail支持我的項目:的Maven的JarClassLoader:警告:讓Foo.class在X.jar隱藏byY.jar(具有不同的字節碼)

 <dependency> 
     <groupId>javax.mail</groupId> 
     <artifactId>mail</artifactId> 
     <version>1.4.1</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.activation</groupId> 
     <artifactId>activation</artifactId> 
     <version>1.1.1</version> 
    </dependency> 

我開始收到洪水警告信息像這樣的(當我運行內置的jar):

JarClassLoader: Warning: javax/mail/Address.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode) 
JarClassLoader: Warning: javax/mail/AuthenticationFailedException.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with differ 
ent bytecode) 
JarClassLoader: Warning: javax/mail/Authenticator.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode) 
JarClassLoader: Warning: javax/mail/BodyPart.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode) 
JarClassLoader: Warning: javax/mail/EventQueue.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode) 
JarClassLoader: Warning: javax/mail/FetchProfile$Item.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode 
) 

我的程序運行良好(併發送電子郵件罰款),但我不希望所有這些數以百計的JarClassLoader警告...

任何想法如何休息礦石和平&安靜我的控制檯日誌?


更新:多虧了Jigar喬希尖端下方,我發現不需要Geronimo的javamail_1.4_spec-1.7.1.jar來自org.apache.cxf:CXF-API中:jar:2.7 1.1:編譯,所以我加了一個排除:

<dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-api</artifactId> 
     <version>2.7.1</version> 
     <exclusions> 
      <exclusion> 
      <groupId>org.apache.geronimo.specs</groupId> 
      <artifactId>geronimo-javamail_1.4_spec</artifactId> 
     </exclusion> 
     </exclusions> 
    </dependency> 

而且mvn dependency:tree命令不再顯示「的Geronimo」作爲依賴,但我仍然得到所有這些警告,當我運行新產生的JAR(建從乾淨!)

附加su ggestions?


更新2:這是依賴關係部分中我的pom.xml

<dependencies> 
    <dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>3.8.1</version> 
    <scope>test</scope> 
    </dependency> 


    <dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-rt-frontend-jaxws</artifactId> 
    <version>2.7.1</version> 
    <type>jar</type> 
    <scope>runtime</scope> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-rt-transports-http</artifactId> 
    <version>2.7.1</version> 
    <type>jar</type> 
    <scope>runtime</scope> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-web</artifactId> 
    <version>3.0.7.RELEASE</version> 
    </dependency> 


    <dependency> 
    <groupId>mysql</groupId> 
    <artifactId>mysql-connector-java</artifactId> 
    <version>5.1.26</version> 
    </dependency> 
    <dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-core</artifactId> 
    <version>4.2.6.Final</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-api</artifactId> 
    <version>2.7.1</version> 
    <exclusions> 
     <exclusion> 
    <groupId>org.apache.geronimo.specs</groupId> 
    <artifactId>geronimo-javamail_1.4_spec</artifactId> 
     </exclusion> 
    </exclusions> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-rt-transports-http</artifactId> 
    <version>2.7.1</version> 
    <type>jar</type> 
    </dependency> 

    <dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.5</version> 
    </dependency> 

    <dependency> 
    <groupId>javax.mail</groupId> 
    <artifactId>mail</artifactId> 
    <version>1.4.1</version> 
    </dependency> 
    <dependency> 
    <groupId>javax.activation</groupId> 
    <artifactId>activation</artifactId> 
    <version>1.1.1</version> 
    </dependency> 

</dependencies> 

回答

2

這一警告說你必須現在從多個罐子同一類,因此它可以在運行時

作祟

例如:

JarClassLoader: Warning: javax/mail/EventQueue.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode) 

我的廟你正在尋找從mail-1.4.1.jar,而不是那類從geronimo-javamail_1.4_spec-1.7.1.jar例如

你將不得不排除這種非想罐子,這樣它不會使自己在類路徑,或者通過使用<exclusions><optional>標籤,它可能是從其他jar的依賴

來執行mvn dependency:tree從那裏來了追查和<exclude>


請參見

+0

我們假定你是正確的,非常感謝你的'MVN依賴性:tree'尖。那個不需要的geronimo-javamail jar來自/ with'org.apache.cxf:cxf-api:jar:2.7.1:compile'。我絕對想排除。我會很快檢查如何做到這一點。 – Withheld

+1

https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html –

+0

再次感謝您。我曾嘗試過,但由於某種原因,這似乎無法解決問題(請參閱上面的更新)。 – Withheld