Cannot convert value of type [org.apache.shiro.cache.ehcache.EhCacheManager] to required type [org.

在Spring MVC 3.0项目中集成Thymeleaf时,遇到一个错误,即不能将EhCacheManager转换为ICacheManager。错误源于Thymeleaf和Shiro中都存在名为cacheManager的属性。解决方案包括将cacheManager移入securityManager内部或者更改bean的ID以避免冲突。
摘要由CSDN通过智能技术生成

 在一个springmvc(spring是3.0版本,其对应的thyemleaf也应该是spring3的版本)项目中添加thyemleaf时候,出现这个错误,

 Cannot convert value of type [org.apache.shiro.cache.ehcache.EhCacheManager] to required type [org.thymeleaf.cache.ICacheManager] for property 'cacheManager': no matching editors or conversion strategy found

初看这个错误,从字面意思来看,感觉是对于cacheManager这个属性,没法将[org.apache.shiro.cache.ehcache.EhCacheManager]转换成[org.thymeleaf.cache.ICacheManager] for property 'cacheManager',

于是查看配置文件,发现cacheManager这个属性只有在配置shrio时候用到了 

    <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
        <property name="sessionManager" ref="sessionManager"/>
        <property name="authenticator" ref="authenticator"/>
        <property name="cacheManager" ref="cacheManager"/>
        <property name="realms">
            <array>
                <ref bean="ticketRealm"/>
            </array>
        </property>
    </bean>

    <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        <property name="cacheManagerConfigFile" value="classpath:com/jdjr/ft/sso/api/ehcache/ehcache.xml"/>
    </bean>

 所以我猜测应该是thyemleaf中有个属性也叫cacheManager,由于在这里注册了bean,所以这个属性先去spring容器里面拿来用了,于是百度,终于找到了这篇文章https://blog.csdn.net/baokx/article/details/50470908,按照博主给的参考,给出了解决方法1,即直接把cacheManager拿到securityManager内部来,发现项目正常启动

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
        <
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值