Spring ehcache查找了错误的CacheManager

丹尼尔·奥坎波(Daniel Ocampo)

我正在尝试为我的项目配置带有春天注释的ehcache,并且出现此异常:

无法将[org.springframework.cache.ehcache.EhCacheCacheManager]类型的值转换为属性'cacheManager'所需的[net.sf.ehcache.CacheManager]类型

我的上下文应用文件是这样的:

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/util
   http://www.springframework.org/schema/util/spring-util-3.0.xsd       
   http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring
   http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-        spring-1.1.xsd">
<ehcache:annotation-driven/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"     p:cache-manager-ref="ehcache" />
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="/WEB-INF/ehcache.xml"/>
</beans>

我做错了什么?如果我将net.sf.ehcache.CacheManager的rg.springframework.cache.ehcache.EhCacheCacheManager更改为另一个异常。

谢谢您能给我的任何帮助。

最好的祝福。

伊库门

您正在手动创建一个Spring CacheManager,并且它被机制隐式使用(由于它是“ cacheManager” ID)annotation-driven注释机制实际上将为您完成此操作,但是它需要底层的缓存实现。因此,将您的代码更改为以下内容:

<ehcache:annotation-driven/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" 
    p:configLocation="/WEB-INF/ehcache.xml"/>

注意:您可以摆脱

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"     p:cache-manager-ref="ehcache" />

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Spring Ehcache MBean监视

来自分类Dev

Spring Boot EHcache cacheResolver

来自分类Dev

cmake找不到Boost库,因为它查找了错误的文件名

来自分类Dev

Spring框架中的ehcache配置

来自分类Dev

通过Spring / MyBatis了解EhCache

来自分类Dev

使用Spring的cut ehcache逐出策略

来自分类Dev

使用Spring / EHCache加载时刷新缓存

来自分类Dev

Spring Boot,使用EhCache进行缓存

来自分类Dev

使用Spring以编程方式驱逐Ehcache元素

来自分类Dev

Ehcache Java Spring MVC和分页@Cacheable

来自分类Dev

使用Spring的cut ehcache逐出策略

来自分类Dev

使用Spring / EHCache加载时刷新缓存

来自分类Dev

无法启动EHCache和Spring Boot

来自分类Dev

Spring Boot不会初始化Ehcache

来自分类Dev

将ehcache:proxy迁移到spring 4

来自分类Dev

使用 ehcache 的 Spring 实现配置 JMX?

来自分类Dev

多Maven项目中的Spring Boot ehcache

来自分类Dev

我在ehcache上遇到问题,但收到错误消息“无法为XML模式名称空间[http://www.ehcache.org/v3]定位Spring NamespaceHandler”

来自分类Dev

Spring的Spring的Class Cast异常错误

来自分类Dev

Spring Boot WhiteLabel 错误页面 (Spring 4.0)

来自分类Dev

Spring Boot EnableJpaRepositories错误

来自分类Dev

java Spring导入错误

来自分类Dev

RestEasy Spring集成错误

来自分类Dev

Spring Security部署错误

来自分类Dev

Spring Integration错误日志

来自分类Dev

java ee spring错误

来自分类Dev

Spring集成聚合错误

来自分类Dev

Spring Security StackOverflow错误

来自分类Dev

Spring Integration Bean错误