我正在尝试将我的应用程序连接到Terracotta缓存集群,但我在启动应用程序时遇到了困难,因为我已经设置了配置。控制台中没有任何错误,但是如果我继续调试,它在尝试创建CacheManager时会失败。
我得到的错误是这个。原因: net.sf.ehcache.config.TerracottaConfigConfiguration:java.lang.ClassNotFoundException
我使用Hibernate 4.x,Spring4.x,Terracotta BigMemory Max 4.x。
,你能告诉我我做错了什么或者在哪里可以找到最新的文档吗?
以下是我的配置:
Hibernate属性:
<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>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>我在Windows上,启动了Terracotta服务器和管理控制台。服务器显示为active,但没有连接到它的客户端。
我尝试使用类似于我自己的环境来找到有效配置的例子,但是找不到。
谢谢!
发布于 2016-01-13 10:05:12
你在你的类路径中丢失了ehcache-core。添加以下依赖项以使其工作:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.1.1</version>
</dependency>发布于 2016-03-19 21:02:52
恐怕你做不到。我不知道用Hibernate 4.x支持Terracotta 4.1的代码库(甚至是非官方代码)。很可能是我的记忆让我在这里失忆了,但是.
您可以尝试的最好方法是使用Ehcache嵌入式Hibernate 2LC提供程序类(在net.sf.ehcache包中),但我认为这些类不支持Hibernate 4.xSPI。
https://stackoverflow.com/questions/34750392
复制相似问题