小编gof*_*frm的帖子

@Configurable-Beans 在 Spring Boot 中不能与 JPA-EntityListeners 一起工作

我在 Spring Boot 应用程序中创建的自定义 jpa-entity 侦听器有一个奇怪的问题。我正在尝试使用 Springs@Configurable机制来配置 EntityListener (如 Springs 中所见AuditingEntityListener),但是一旦在@EntityListenersjpa 实体的-Annotation 中使用了我的 Listener ,Spring 就会拒绝识别它。如果未在 jpa 实体上配置它,则 Spring 会按其应有的方式连接/配置侦听器。

我创建了一个带有 junit-test 的示例项目来演示这个问题:https : //github.com/chrisi/aopconfig/find/master

@SpringBootApplication
@EnableSpringConfigured
@EnableLoadTimeWeaving
public class Application {

  public static void main(String[] args) throws Exception {
    SpringApplication.run(Application.class, args);
  }
}
Run Code Online (Sandbox Code Playgroud)

实体监听器:

/**
 * This bean will NOT be instanciated by Spring but it should be configured by Spring
 * because of the {@link Configurable}-Annotation.
 * <p>
 * The configuration …
Run Code Online (Sandbox Code Playgroud)

spring jpa entitylisteners spring-data-jpa

5
推荐指数
0
解决办法
1081
查看次数

标签 统计

entitylisteners ×1

jpa ×1

spring ×1

spring-data-jpa ×1