Spring整合redis出错

真是有意思 2016-04-28 06:45:31
2016-04-28 18:50:16 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.interceptor.CacheInterceptor#0': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.crazycake.shiro.RedisCacheManager' to required type 'org.springframework.cache.CacheManager' for property 'cacheManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.crazycake.shiro.RedisCacheManager' to required type 'org.springframework.cache.CacheManager' for property 'cacheManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:474)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 20 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
... 26 common frames omitted
四月 28, 2016 6:50:16 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.interceptor.CacheInterceptor#0': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.crazycake.shiro.RedisCacheManager' to required type 'org.springframework.cache.CacheManager' for property 'cacheManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.crazycake.shiro.RedisCacheManager' to required type 'org.springframework.cache.CacheManager' for property 'cacheManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:474)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 20 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
... 26 more
...全文
335 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
w5325698 2016-05-18
  • 打赏
  • 举报
回复
你检查下jar包版本及bean id是否都是一一对应的。不是对应的就会找不到。还有,你看下类的继承及实现关系。
sunshingheavy 2016-05-03
  • 打赏
  • 举报
回复
Redis怎么会和shiro联系上了? 没搞过....
  • 打赏
  • 举报
回复
  • 打赏
  • 举报
回复
Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found 参考
真是有意思 2016-05-03
  • 打赏
  • 举报
回复
引用 3 楼 w5325698 的回复:
Failed to convert property value of type 'org.crazycake.shiro.RedisCacheManager' to required type 'org.springframework.cache.CacheManager' for property 'cacheManager' 配置不对,你配置项配置 cacheManager. 需要配置对应的bean:org.springframework.cache.CacheManager'的解析类
<cache:annotation-driven /> jedis客户端连接工厂 <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:host-name="127.0.0.1" p:port="6379" /> redisTemplate模板 <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connection-factory-ref="jedisConnectionFactory" /> redis缓存管理器 <bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:template-ref="redisTemplate" /> 以上为我在spring-mvc.xml的配置。 spring-shiro.xml的"cacheManager"bean我尝试过改名,没有作用依旧抛出这个错误。
真是有意思 2016-05-03
  • 打赏
  • 举报
回复
引用 2 楼 tianfang 的回复:
配置文件解析错误 RedisCacheManager 贴出来看看吧
这个是maven的包,<dependency> <groupId>org.crazycake</groupId> <artifactId>shiro-redis</artifactId> <version>2.4.2.1-RELEASE</version> </dependency>
真是有意思 2016-05-03
  • 打赏
  • 举报
回复
引用 8 楼 sunshingheavy 的回复:
Redis怎么会和shiro联系上了? 没搞过....
项目是shiro+spring+redis
真是有意思 2016-05-03
  • 打赏
  • 举报
回复
引用 6 楼 shijing266 的回复:
Cannot convert value of type [org.crazycake.shiro.RedisCacheManager] to required type [org.springframework.cache.CacheManager] for property 'cacheManager': no matching editors or conversion strategy found 参考
感谢回复,问题依旧存在。 感觉教程本身就有问题,教程地址http://blog.csdn.net/qinsihang/article/details/22722253 有更好的方案代替么?这个错误估计很难解决,换个方案。
w5325698 2016-05-02
  • 打赏
  • 举报
回复
Failed to convert property value of type 'org.crazycake.shiro.RedisCacheManager' to required type 'org.springframework.cache.CacheManager' for property 'cacheManager' 配置不对,你配置项配置 cacheManager. 需要配置对应的bean:org.springframework.cache.CacheManager'的解析类
attilax 2016-05-02
  • 打赏
  • 举报
回复
JedisPool jedisPool = new JedisPool("localhost", 6379); Jedis jedis = null; try { jedis = jedisPool.getResource(); Set<String> keys= jedis.keys("*"); for (String k : keys) { System.out.println(k); System.out.println(jedis.get(k)); System.out.println("----"); } // jedis.set("rediskey1", "redisvalue1"); // jedis.set("rediskey2", "redisvalue2"); // System.out.println(jedis.get("rediskey1")); // System.out.println(jedis.get("rediskey2")); } catch (Exception e) { e.printStackTrace(); } finally { if (jedis != null) jedis.close(); } jedisPool.destroy();
tianfang 2016-05-02
  • 打赏
  • 举报
回复
配置文件解析错误 RedisCacheManager 贴出来看看吧

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧