2012-02-15 52 views
1

我正在爲我的Grails項目添加一個依賴項,它將commons-logging和log4j作爲傳遞依賴項。當我運行我的應用程序然後我得到一個錯誤Log4J問題在Grails應用程序中依賴於comons-logging

Error Error executing script RunApp: Could not initialize class 
org.apache.log4j.LogManager (NOTE: Stack trace has been filtered. Use --verbose to see 
entiretrace.) java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.log4j.LogManager 

我試圖通過排除共享記錄刪除共享記錄依賴按this link。但它從來沒有幫助。我看到commons-logging不是我所添加的依賴關係的直接依賴。所以如果做

runtime ('com.company.i18n:i18n:1.3.4') 
    { 
     excludes 'commons-logging' 
    } 

它是否排除我的依賴項中的所有commons-logging依賴項?或者只有直接的。我該如何解決這個問題?

回答

1

我努力通過從所有的依賴項中排除「log4j」,但沒有任何工作。最後,我通過避免所有的傳遞依賴並且添加了必要的東西來解決這個問題。

//add necessary dependencies. 

runtime ('com.company.i18n:i18n:1.3.4') 
{ 
    transitive = false 
} 
+0

謝謝這也解決了我和grails和xmlapis之間的衝突!這讓我瘋狂,直到我看到這個終於奏效的東西!將此添加到build.groovy - >運行時( 'XML的API:XML的API:04年3月1日') \t \t \t { \t \t \t \t及物=假 \t \t \t} – msanjay 2012-08-08 12:35:48