ehcache主配置如下:
<!-- 配置ehcache缓存管理器 -->
<!-- 配置一个简单的缓存工厂bean对象 -->
<!-- 使用缓存 关联ehcache.xml中的缓存配置 -->
<!-- 配置一个缓存拦截器对象,处理具体的缓存业务 -->
<!-- 配置一个缓存拦截器对象,处理具体的缓存业务 -->
<!-- 参与缓存的切入点对象 (切入点对象,确定何时何地调用拦截器) -->
<!-- 配置缓存aop切面 -->
<!-- 配置哪些方法参与缓存策略 -->
<!--
.表示符合任何单一字元
### +表示符合前一个字元一次或多次
### 表示符合前一个字元零次或多次
### \Escape任何Regular expression使用到的符号
-->
<!-- .表示前面的前缀(包括包名) 表示print方法-->
<!--
com.scxxs.dao.*get*
com.scxxs.dao.*find*
com.scxxs.dao.*query*
-->
.*find.*
<!-- 当发生create,save,insert,update,delete,remove等方法时,就会去flush一下 -->
.*add.*
ehcache.xml配置如下:
<!-- 设置缓存文件 .data 的创建路径。
如果该路径是 Java 系统参数,当前虚拟机会重新赋值。
下面的参数这样解释:
user.home – 用户主目录
user.dir – 用户当前工作目录
java.io.tmpdir – 默认临时文件路径 -->
<defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="30" timeToLiveSeconds="30" overflowToDisk="false"/>
<!--
配置自定义缓存
maxElementsInMemory:缓存中允许创建的最大对象数
eternal:缓存中对象是否为永久的,如果是,超时设置将被忽略,对象从不过期。
timeToIdleSeconds:缓存数据的钝化时间,也就是在一个元素消亡之前,
两次访问时间的最大时间间隔值,这只能在元素不是永久驻留时有效,
如果该值是 0 就意味着元素可以停顿无穷长的时间。
timeToLiveSeconds:缓存数据的生存时间,也就是一个元素从构建到消亡的最大时间间隔值,
这只能在元素不是永久驻留时有效,如果该值是0就意味着元素可以停顿无穷长的时间。
overflowToDisk:内存不足时,是否启用磁盘缓存。
memoryStoreEvictionPolicy:缓存满了之后的淘汰算法。
-->
<cache name="SimplePageCachingFilter"
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="900"
timeToLiveSeconds="1800"
memoryStoreEvictionPolicy="LFU" />
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="true"
timeToIdleSeconds="1800"
timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LFU" />
applicationContext.xml spring主配置如下:
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
com.mysql.jdbc.Driver
jdbc:mysql://127.0.0.1:3306/mytest
root
root
<!-- 配置事务管理器 -->
<bean id="transcationManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:ibatis/SqlMapConfig.xml" />
<!--src/ WEB-INF/<property name="mapperLocations" value="classpath*:com/xxt/ibatis/dbcp/domain/user.map.xml"/ > -->
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transcationManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置AOP切入点 -->
<aop:config>
<aop:pointcut id="allManagerMethod"
expression="execution(* com.scxxs.dao.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" />
</aop:config>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>
<import resource="spring/applicationContext_dao.xml"/>
<import resource="spring/applicationContext_biz.xml"/>
<import resource="spring/applicationContext_ehcache.xml"/>
我遇到的问题就是,ehcache在配置两个切面的时候报错:
2013-01-06 14:33:38Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1aaf64d: defining beans [dataSource,transcationManager,sqlSessionFactory,sqlSession,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,allManagerMethod,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,jdbcTemplate,springDemoDao,userDao,userBiz,cacheManager,simpleCache,methodCacheInterceptor,methodCacheAfterAdvice,methodCachePointCut,methodCachePointCutAdvice]; root of factory hierarchy
2013-01-06 14:33:38Retrieved dependent beans for bean 'cacheManager': [simpleCache]
2013-01-06 14:33:38Retrieved dependent beans for bean 'simpleCache': [methodCacheAfterAdvice]
2013-01-06 14:33:38Retrieved dependent beans for bean 'methodCacheAfterAdvice': [methodCachePointCutAdvice]
2013-01-06 14:33:38Invoking destroy() on bean with name 'cacheManager'
2013-01-06 14:33:38Shutting down EHCache CacheManager
2013-01-06 14:33:38Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:86)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:100)
at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:107)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:880)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:852)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:446)
... 34 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 50 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 56 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 62 more
2013-1-6 14:33:38 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 'dataSource' defined in class path resource [applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCachePointCut' defined in class path resource [spring/applicationContext_ehcache.xml]: Cannot resolve reference to bean 'methodCacheInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:86)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:100)
at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:107)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:880)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:852)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:446)
... 34 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodCacheInterceptor' defined in class path resource [spring/applicationContext_ehcache.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 50 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'net.sf.ehcache.Cache' for property 'cache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 56 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing net.sf.ehcache.terracotta.InternalEhcache,net.sf.ehcache.store.StoreListener,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [net.sf.ehcache.Cache] for property 'cache': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 62 more
我试过删除一个切面的话项目是能够完全启动的,
<bean id="simpleCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager" ref="cacheManager" />
<!-- 使用缓存 关联ehcache.xml中的缓存配置 -->
<property name="cacheName" value="mobileCache" />
</bean>
<bean id="methodCachePointCut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<!-- 配置缓存aop切面 -->
<property name="advice" ref="methodCacheInterceptor" />
<!-- 配置哪些方法参与缓存策略 -->
<!--
.表示符合任何单一字元
### +表示符合前一个字元一次或多次
### *表示符合前一个字元零次或多次
### \Escape任何Regular expression使用到的符号
-->
<!-- .*表示前面的前缀(包括包名) 表示print方法-->
<property name="patterns">
<list>
<!--
<value>com.scxxs.dao.*get*</value>
<value>com.scxxs.dao.*find*</value>
<value>com.scxxs.dao.*query*</value>
-->
<value>.*find.*</value>
</list>
</property>
</bean>
像上面这种配置有两个删除其中一个都没问题。我还测试过缓存起作用没,当我删除后面那个after切面后项目正常启动且缓存起作用,请教各位大虾为了我两个切面都存在的时候就要报错,报错信息就是上面那种,搞不懂啊!!!!