如何在Richfaces 4.3.7中使用Google Guice

时间:2015-08-31 21:05:49

标签: richfaces guava guice jsf-2.2

我编写了一个使用richfaces 4.3.7和google guice 4.0的网络应用程序。

问题是使用guava 16使用guava 18和google guice的richfaces,结果如下:

java.lang.RuntimeException: java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class org.richfaces.resource.ResourceLibraryFactoryImpl
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class org.richfaces.resource.ResourceLibraryFactoryImpl

有谁知道解决方案?我使用gradle进行依赖管理。

更新

dependencies {
compile 'com.sun.faces:jsf-api:2.2.9'
compile 'com.sun.faces:jsf-impl:2.2.9'
compile 'jstl:jstl:1.2'
compile 'org.hibernate:hibernate-core:4.3.6.Final'
compile 'mysql:mysql-connector-java:5.1.31'
compile 'com.google.inject:guice:4.0'
compile 'org.richfaces.core:richfaces-core-api:4.3.7.Final'
compile 'org.richfaces.core:richfaces-core-impl:4.3.7.Final'
compile 'org.richfaces.ui:richfaces-components-api:4.3.7.Final'
compile 'org.richfaces.ui:richfaces-components-ui:4.3.7.Final'
testCompile group: 'junit', name: 'junit', version: '4.+'
}

1 个答案:

答案 0 :(得分:2)

尝试排除Guice子依赖关系,因此它将使用Richfaces Guava版本。

compile 'com.google.inject:guice:4.0' {
  exclude group: 'com.google.guava', module: 'guava'
}