1 如果Spring 配置了事务
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<!-- <property name="proxyTargetClass">
<value>true</value>
</property> -->
<property name="beanNames">
<list>
<!-- 配置需要事务管理的service -->
<value>*Service</value>
<value>*ServiceImpl</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
此时获取的bean 如果是IsequencesService service = (SequencesServiceImpl) context.getBean("sequencesService");
则会出错 修改方法
第一种 打开注释的地方 启用Spring 的cglib
第二种 将 (SequencesServiceImpl) context.getBean("sequencesService");
修改为 java的动态代理 (IsequencesService) context.getBean("sequencesService");
第三种 或者在 配置 service <bean>的地方增加 <aop:scoped-proxy proxy-target-class="true" />