BeanNameAutoProxyCreator 不支持annotation的问题解决方法讨论
有人SpringSource的BBS上提出了问题,但没有人解决
http://forum.springsource.org/showthread.php?t=70355
spring事务配置
<!-- 事务配置 --><bean id="transactionManager" ref="sessionFactory" /></bean><bean id="transationInterceptor" ref="transactionManager" /><property name="transactionAttributes"><props><prop key="save*">PROPAGATION_REQUIRED</prop><prop key="update*">PROPAGATION_REQUIRED</prop><prop key="delete*">PROPAGATION_REQUIRED</prop><prop key="Save*">PROPAGATION_REQUIRED</prop><prop key="merge*">PROPAGATION_REQUIRED</prop><prop key="shield*" >PROPAGATION_REQUIRED</prop></props></property></bean><bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"><property name="beanNames"><value>*ManagerImpl,*Dao,*Service,*ServiceImpl</value></property><property name="interceptorNames"><list><value>transationInterceptor</value></list></property></bean>
上面这样配置事务,在annotation中不启作用的.
解决办法正在查找中...
1 楼 kevinhrw 2009-12-23 这个问题,找了好久,也没没有好的办法.
我也提一个问题.解决了这个问题,我写一总结出来,方便后来人.
[url]
http://www.iteye.com/problems/32854
[/url] 2 楼 kevinhrw 2009-12-24 我找呀,找呀,终于找到答案了.
事务配置成功.
2.5版本的PetClinic范例中有详细阐述。在该范例中,基础构架组件(数据源、事务管理等)结合上文提到的外化属性在XML中定义。数据访问层对象也有部分在XML中定义,它们的配置也都利用了@Autowired注解来简化依赖注入。最后,web层控制器完全不在XML中显式定义,相反,下面提供的这段配置被用来触发所有Web控制器的自动侦测
1.<context:component-scan base-package="com.iit.webapp"/>只能针对Web层,
Service,DAO层不能包含在里面.
如果有多个package,使用","分隔即可.
2.在XML中只需要声明service的名字与class即可,引用可能利用@Autowired注解来简化依赖注入.