Setting Up Annotation Driven Transactions in Spring in @Configuration Class

爱⌒轻易说出口 提交于 2019-12-01 02:27:40

You can now use @EnableTransactionManagement.

See this post for more details: http://blog.springsource.com/2011/06/10/spring-3-1-m2-configuration-enhancements/

It seems like it isn't possible according to this forum post:

there may be a more first-class mechanism for enabling annotation-driven TX in @Configuration classes in Spring 3.1, but in the meantime, the recommended approach is to use @ImportResource to include a snippet of XML that declares <tx:annotation-driven/>

Wait: but you seem to have an XML context anyway. Why not add <tx:annotation-driven/> to it and use @Transactional?

Take a look at http://blog.springsource.com/2011/02/17/spring-3-1-m1-featurespec. Spring 3.1's FeatureSpecification classes such as TxAnnotationDriven are designed to solve exactly the problem described above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!