2012-02-15 47 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