【问题标题】:Spring - Is there a way to enable transaction management in application.properties?Spring - 有没有办法在 application.properties 中启用事务管理?
【发布时间】:2015-11-11 15:50:42
【问题描述】:

我根据https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/transaction/annotation/EnableTransactionManagement.html找到了两种在Spring中启用事务管理的方法:

1 在@Configuration - 带注释的配置类上使用@EnableTransactionManagement 注释。

2 在 Spring XML 配置中设置。

但我的 Spring 项目既没有 @Configuration - 带注释的配置类也没有 Spring XML 配置。

有没有办法在 application.properties 中启用事务管理?

如果答案是否定的,那么我将不得不选择上述的 1 或 2。

谢谢, 安迪

【问题讨论】:

  • 我正在使用 application.properties 文件配置我的应用程序。

标签: java spring transactions entitymanager


【解决方案1】:

答案是否定的,你需要告诉容器它要使用事务。

仅仅告诉你用注释你的类是不够的 @Transactional 注释,将@EnableTransactionManagement 添加到 你的配置

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html

【讨论】:

  • 感谢您的澄清。
猜你喜欢
  • 2013-04-02
  • 2012-05-06
  • 2010-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
相关资源
最近更新 更多