(1)Shiro笔记-整合Ehcache时缺少默认cache配置异常解决
来源:互联网 发布:windows update 在哪 编辑:程序博客网 时间:2024/06/05 03:58
在使用Ehcache配置shiro cacheManager时遇到了如下异常,异常全文:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in URL [file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/SpringMVCTest/WEB-INF/classes/config/spring-shiro-web.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in URL [file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/SpringMVCTest/WEB-INF/classes/config/spring-shiro-web.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'cacheManager' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Caches cannot be added by name when default cache config is not specified in the config. Please add a default cache config in the configuration. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:235) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:703) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5221) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
主要异常信息如下
Caches cannot be added by name when default cache config is not specified in the config. Please add a default cache config in the configuration.
其实异常原因也挺容易明白的,就是缺少了一个默认cache配置,在Ehcache官网上也有相应的说明:
http://www.ehcache.org/documentation/2.8/faq.html
What does the following error mean? “Caches cannot be added by name when default cache config is not specified in the config. Please add a default cache config in the configuration.”
From Ehcache 2.4, the defaultCache is optional. When you try to programmatically add a cache by name, CacheManager.add(String name), a default cache is expected to exist in the CacheManager configuration. To fix this error, add a defaultCache to the CacheManager’s configuration.
很明显,在2.4版本之后,配置Ehcache文件时,开始需要添加一个默认cache配置。问题明白了,就好解决了,在Ehcache配置文件中添加如下代码即可:
<defaultCache maxElementsInMemory="10000" maxElementsOnDisk="0" eternal="true" overflowToDisk="true" diskPersistent="false" timeToIdleSeconds="0" timeToLiveSeconds="0" diskSpoolBufferSizeMB="50" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LFU" />
- (1)Shiro笔记-整合Ehcache时缺少默认cache配置异常解决
- Shiro缓存整合EhCache
- shiro整合ehcache
- Shiro 入门系列 四 (shiro缓冲整合EhCache)
- shiro ehcache配置
- Shiro EHCache缓存配置
- shiro-session-ehcache配置
- Spring mvc+shiro+ehcache整合
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- Spring使用Cache、整合Ehcache
- spring + shiro +ehcache + redis整合自我总结1
- ConcurrentHashMap的特性
- common.js
- IDEA快捷键
- HDU
- 自定义vector,还有几个函数没写(懒得写了)
- (1)Shiro笔记-整合Ehcache时缺少默认cache配置异常解决
- Java和JVM简史
- SQL Server触发器语法格式
- box-shadow,font-size=0
- Spring学习心得
- npm安装sass
- 如何在dos命令中查看class的jvm文件
- Java命名规则
- keystore 介绍