如何在Richfaces 4.3.7中使用Google Guice [英] How to use Google Guice with Richfaces 4.3.7

查看:90
本文介绍了如何在Richfaces 4.3.7中使用Google Guice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用richfaces 4.3.7和google guice 4.0的网络应用程序.

I'm programming a web app which uses richfaces 4.3.7 and google guice 4.0.

问题是使用番石榴18的richfaces和使用番石榴16的google guice会导致以下异常:

The problem is that richfaces using guava 18 und google guice using guava 16, this results with the following Exception:

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进行依赖项管理.

Does anyone know a solution? I'm using gradle for dependency management.

更新:

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.+'
}

推荐答案

尝试排除Guice的从属关系,因此它将使用Richfaces Guava版本.

Try to exclude Guice subdependency, so it will use Richfaces Guava version.

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

这篇关于如何在Richfaces 4.3.7中使用Google Guice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆