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>