【发布时间】:2012-03-27 01:34:12
【问题描述】:
我正在尝试使用 Hibernate 3.5.5 在现有 Spring 3.1.1 应用程序中启用对象缓存。我正在使用 ehcache 2.2.0。在我的 applicationContext 中,我添加了使用 EHCache 开启缓存的配置。
<cache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cache-manager="ehcache" />
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="ehcache.xml" />
然后我创建了 ehcache.xml 文件:
<diskStore path="java.io.tmpdir" />
<defaultCache
eternal="false"
maxElementsInMemory="1000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
memoryStoreEvictionPolicy="LRU"/>
<cache name="studentCache"
eternal="false"
maxElementsInMemory="10000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
memoryStoreEvictionPolicy="LRU" />
我在 pom.xml 文件中为 ehcache 添加了必要的依赖项。但是现在我收到了这个错误:
bean 初始化失败; 嵌套异常是 org.springframework.beans.ConversionNotSupportedException: 无法将类型“java.lang.String”的属性值转换为所需类型 属性“cacheManager”的“net.sf.ehcache.CacheManager”; 嵌套异常是 java.lang.IllegalStateException: 无法将类型 [java.lang.String] 的值转换为所需类型 [net.sf.ehcache.CacheManager] 用于属性“cacheManager”: 未找到匹配的编辑器或转换策略
有人知道是什么原因造成的吗?
【问题讨论】:
标签: java spring hibernate ehcache