org.springframework.beans.MethodInvocationException: Property 'cacheManager' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Caches cannot be
shiro cache manage配置报错:
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:1471) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1216) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:232) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465) 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:4973) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 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)
需要在ehcahe.xml在加入默认配置
1 <?xml version="1.0" encoding="UTF-8"?> 2 <ehcache updateCheck="false" name="shirocache"> 3 <diskStore path="java.io.tmpdir"/> 4 <defaultCache 5 maxElementsInMemory="10000" 6 maxElementsOnDisk="0" 7 eternal="true" 8 overflowToDisk="true" 9 diskPersistent="false" 10 timeToIdleSeconds="0" 11 timeToLiveSeconds="0" 12 diskSpoolBufferSizeMB="50" 13 diskExpiryThreadIntervalSeconds="120" 14 memoryStoreEvictionPolicy="LFU" 15 /> 16 <!-- 登录记录缓存 锁定10分钟 --> 17 <cache name="passwordRetryCache" 18 maxEntriesLocalHeap="2000" 19 eternal="false" 20 timeToIdleSeconds="3600" 21 timeToLiveSeconds="0" 22 overflowToDisk="false" 23 statistics="true"> 24 </cache> 25 <cache name="authorizationCache" 26 maxEntriesLocalHeap="2000" 27 eternal="false" 28 timeToIdleSeconds="3600" 29 timeToLiveSeconds="0" 30 overflowToDisk="false" 31 statistics="true"> 32 </cache> 33 <cache name="authenticationCache" 34 maxEntriesLocalHeap="2000" 35 eternal="false" 36 timeToIdleSeconds="3600" 37 timeToLiveSeconds="0" 38 overflowToDisk="false" 39 statistics="true"> 40 </cache> 41 <cache name="shiro-activeSessionCache" 42 maxEntriesLocalHeap="2000" 43 eternal="false" 44 timeToIdleSeconds="3600" 45 timeToLiveSeconds="0" 46 overflowToDisk="false" 47 statistics="true"> 48 </cache> 49 <cache name="shiro_cache" 50 maxElementsInMemory="2000" 51 maxEntriesLocalHeap="2000" 52 eternal="false" 53 timeToIdleSeconds="0" 54 timeToLiveSeconds="0" 55 maxElementsOnDisk="0" 56 overflowToDisk="true" 57 memoryStoreEvictionPolicy="FIFO" 58 statistics="true"> 59 </cache> 60 </ehcache>