【问题标题】:Spring is not creating the bean for @service annotated class when one of its method is annotated with @transactional当 Spring 的方法之一使用 @transactional 注释时,Spring 不会为 @service 注释类创建 bean
【发布时间】:2021-07-20 17:11:18
【问题描述】:

Spring 应用程序无法启动,因为它无法为使用 @Service 注释的类找到要在配置类中自动装配的 bean。但它仅在我使用 @Transactional 注释该特定服务类中的方法时发生。为什么会这样?

【问题讨论】:

  • 请分享开始日志
  • 请附上代码示例

标签: java spring spring-boot spring-data-jpa spring-data


【解决方案1】:

当你通过 @Transactional 注释你的类时,spring 使用 AOP,如果你的类是最终的并且没有接口,它不能在你的类上创建代理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多