spring的配置文件换成了用拦截器来代理事务,Tomcat启动报如题所示的错误,找到的原因如下:
解决办法是:
在事务中加上下面语句
<property name="proxyTargetClass" >
<value>true</value>
</property>
表示proxy代理的是类而不是接口。
<!-- 拦截器 --> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="transactionManager" /> <!-- 配置事务属性 --> <property name="transactionAttributes"> <props> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="proxyTargetClass"> <value>true</value> </property> <property name="beanNames"> <list> <value>*DAO</value> </list> </property> <property name="interceptorNames"> <list> <value>transactionInterceptor</value> </list> </property> </bean>
本文解决了使用Spring配置文件中采用拦截器代理事务时遇到的Tomcat启动错误问题。通过在事务配置中添加proxyTargetClass=true,使得AOP代理针对类而非接口。此外,详细展示了如何配置事务拦截器及自动代理创建。
4323

被折叠的 条评论
为什么被折叠?



