<!-- 配置事务管理器 -->
<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
<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
解决方案 »
- 在JS中怎得到JSP中的值
- 求JSP简单的网站实例
- javascript:void(0)是什么意思?
- getBytes("ISO-8859-1");问题
- 请教:JSP代码中定义的数据,如何作为参数被JS定义的函数调用?代码如下
- struts action
- 求助入门Java Web Service
- jsp中怎样实现按钮对textarea中字体编辑功能
- 高手求救:在任何一个页面A登陆后都回到页面A,而不是登陆成功页面!(请看详细内容)
- 找书?!!!!!!!!!!!!!
- 请教各位大侠显示数字页码分页问题
- javamail发送邮件 选择附件错误 java.io.FileNotFoundException: Source
<!-- 配置一个简单的缓存工厂bean对象 -->
<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切面后项目正常启动且缓存起作用,请教各位大虾为了我两个切面都存在的时候就要报错,报错信息就是上面那种,搞不懂啊!!!!