Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
EHCache,hibernate terracotta版本_Hibernate_Ehcache_Terracotta - Fatal编程技术网

EHCache,hibernate terracotta版本

EHCache,hibernate terracotta版本,hibernate,ehcache,terracotta,Hibernate,Ehcache,Terracotta,我有一个运行Hibernate 4.1.7的应用程序,我使用ehcache作为2级缓存。我知道从Hibernate4开始,我需要使用Hibernate附带的ehcache jar,但是这些jar已经很旧了 当前最新版本的ehcache是2.6.3,但hibernate 4.1.7附带的版本是2.4.3。问题是hibernate没有与ehcache terracotta jar捆绑在一起,而我的terracotta服务器与ehcache hibernate 2.6.2 jar捆绑在一起,因为它是t

我有一个运行Hibernate 4.1.7的应用程序,我使用ehcache作为2级缓存。我知道从Hibernate4开始,我需要使用Hibernate附带的ehcache jar,但是这些jar已经很旧了

当前最新版本的ehcache是2.6.3,但hibernate 4.1.7附带的版本是2.4.3。问题是hibernate没有与ehcache terracotta jar捆绑在一起,而我的terracotta服务器与ehcache hibernate 2.6.2 jar捆绑在一起,因为它是terracotta的最新工作版本。我正在努力让我的应用程序连接到terracotta服务器,并假设这是因为版本不匹配

我如何让hibernate(版本2.4.3)使用我的ehcache来连接我的terracotta服务器,该服务器为ehcache版本2.6.2提供服务


如果您使用Hibernate JPA实现,请提供帮助,您应该在persistence.xml中提供以下属性:

<property name="hibernate.cache.region.factory_class" value="net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory" />

然后在类路径中应该有以下JAR(对于terracotta 3.6.5版-与JDK5兼容的最新版本):

  • ehcache-core-ee-2.5.6.jar
  • ehcache-terracotta-ee-2.5.6.jar
  • terracotta-toolkit-1.5-runtime-ee-4.5.0.jar
此外,您必须确保在类路径上没有任何其他ehcache jar

如果您使用maven,那么:

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-core-ee</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-terracotta-ee</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>org.terracotta</groupId>
    <artifactId>terracotta-toolkit-1.5-runtime-ee</artifactId>
    <version>4.5.0</version>
</dependency>

net.sf.ehcache
EHEE核心缓存
2.5.6
net.sf.ehcache
ehcache陶土
2.5.6
兵马俑
terracotta-toolkit-1.5-runtime-ee
4.5.0
另外,不要忘记指向terracotta的maven存储库下载所需的JAR:

<repository>
    <id>terracotta-repository</id>
    <url>http://www.terracotta.org/download/reflector/releases</url>
    <releases>
        <enabled>true</enabled>
    </releases>
</repository>

兵马俑仓库
http://www.terracotta.org/download/reflector/releases
真的

我也遇到过类似的问题。基本上,您可以删除旧的Hibernate EHCache jar并使用新的jar(或者是您自己带来的,或者是通过某个库带来的)。在这里查看我自己对自己(类似)问题的回答:但我读到您必须使用hibernate捆绑的ehcache,这不是真的吗?我可以只使用最新的ehcache吗?不,在我的示例中,我尝试使用最新的ehcache,起初由于Hibernate的(旧的)ehcache而失败,然后使用Maven从项目中删除Hibernate的ehcache库,Terracotta与EhcacheAPI集成的方式是,您必须使用现有EhcacheJAR的类路径,而将Terracotta jar放在其中(我在下面的回答中提供了所需的jar名称)