Java 如何将terracottaehcache与hibernate集成

Java 如何将terracottaehcache与hibernate集成,java,spring,hibernate,ehcache,terracotta,Java,Spring,Hibernate,Ehcache,Terracotta,我正在尝试将我的应用程序连接到Terracotta缓存集群,但我无法使用我设置的配置启动我的应用程序。我在控制台中没有收到任何错误,但是如果我使用debug,它在尝试创建CacheManager时会失败 我得到的错误是这样的。原因:java.lang.ClassNotFoundException:net.sf.ehcache.config.TerracottaConfigConfiguration 我正在使用Hibernate4.x、Spring4.x、TerracottaBigMemory M

我正在尝试将我的应用程序连接到Terracotta缓存集群,但我无法使用我设置的配置启动我的应用程序。我在控制台中没有收到任何错误,但是如果我使用debug,它在尝试创建CacheManager时会失败

我得到的错误是这样的。原因:java.lang.ClassNotFoundException:net.sf.ehcache.config.TerracottaConfigConfiguration

我正在使用Hibernate4.x、Spring4.x、TerracottaBigMemory Max 4.x

您能告诉我我做错了什么,或者在哪里可以找到最新的文档吗?

以下是我的配置:

休眠属性:

<prop key="hibernate.cache.use_structured_entries">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="net.sf.ehcache.configurationResourceName">ehcache-hibernate.xml</prop>
true
真的
org.hibernate.cache.ehcache.EhCacheRegionFactory
真的
ehcache-hibernate.xml
Ehcache-hibernate.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache name="ehcache-hibernate"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="ehcache.xsd">

<cache name="User" maxElementsInMemory="1000"
       maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="3600"
       timeToLiveSeconds="1200" memoryStoreEvictionPolicy="LFU">
    <terracotta />
</cache>

<defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="1200"
        timeToLiveSeconds="1200">
    <!--<terracotta />-->
</defaultCache>
<terracottaConfig url="localhost:9510" />

Maven相关依赖项:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    <version>4.3.10.Final</version>
</dependency>
<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-terracotta</artifactId>
    <version>2.1.1</version>
</dependency>
<dependency>
    <groupId>org.terracotta</groupId>
    <artifactId>terracotta-toolkit-1.6-runtime-ee</artifactId>
    <version>5.8.0</version>
</dependency>
<dependency>
    <groupId>org.terracotta</groupId>
    <artifactId>terracotta-toolkit-runtime-ee</artifactId>
    <version>4.1.1</version>
</dependency>

org.hibernate
休眠ehcache
4.3.10.最终版本
net.sf.ehcache
陶土
2.1.1
兵马俑
terracotta-toolkit-1.6-runtime-ee
5.8.0
兵马俑
terracotta工具包运行时ee
4.1.1
我在Windows上,启动了Terracotta服务器和管理控制台。服务器显示为活动,但没有连接到它的客户端

我曾尝试使用类似于我自己的环境来查找有效配置的示例,但找不到任何示例


谢谢大家!

类路径中缺少
ehcache-core
。添加以下依赖项以使其正常工作:

<dependency>
  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache-core</artifactId>
  <version>2.1.1</version>
</dependency>

net.sf.ehcache
ehcache内核
2.1.1

我担心你无法让它工作。我不知道有哪种代码库(甚至是非官方的)支持Terracotta4.1和Hibernate4.x。这很可能是我的记性不好,但是


您可以尝试的最好方法是使用Ehcache嵌入式Hibernate 2LC提供程序类(在
net.sf.Ehcache
包中),但我认为这些类不支持Hibernate 4.x SPI

我们需要一个错误消息。似乎我有一个日志问题,错误没有出现。我明白了:原因是:java.lang.ClassNotFoundException:net.sf.ehcache.config.terracottaconfigconfiguration问题是hibernate 4.x包含ehcache核心。在我的例子中,我得到了ehcache核心版本2.4.3,它不包含net.sf.ehcache.config.TerracottaConfigConfiguration类。我试图强制应用程序使用ehcache core version 2.1.1,但随后出现以下错误:java.lang.NoSuchMethodError:net.sf.ehcache.config.TerracottaConfiguration.GetNonSopConfiguration()Lnet/sf/ehcache/config/NonSopConfiguration;最好将toterracotta ehcache升级到2.4.3。您当前仅使用2.1.1,这可能与hibernate引入的ehcache内核不兼容。