如何使RepositoryEventHandler在Spring Boot中工作

时间:2018-11-28 23:59:18

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

@Component
@RepositoryEventHandler({Person.class})
public class RepositoryListener  {
@HandleBeforeDelete
public void handleEventBeforeDelete(Person person){
    java.lang.System.out.println("handleAuthorBeforeCreate");
}
@HandleAfterDelete
public void handleEventAfterDelete(Person person){
    java.lang.System.out.println("handleAuthorAfterCreate");
}
@HandleBeforeSave
public void handleEventBeforeSave(Event event){
    java.lang.System.out.println("handleAuthorBeforeSave");
}
@HandleAfterSave
public void handleEventAfterSave(Perrson person){
    java.lang.System.out.println("yulin-11 handleAuthorAfterSave");
}
@HandleBeforeCreate
public void handEventBeforeCreate(Person person){
    java.lang.System.out.println("handEventBeforeCreate");
}
@HandleAfterCreate
public void handleEventAfterCreate(Person person){
    java.lang.System.out.println("handleEventAfterCreate");
}
}

我如上所述创建RepositoryListener。当我在控制器中触发delete和post rest调用时,它不会在RepositoryListener中调用任何这些方法。 (人员是我的领域课程)。有人知道我在想什么吗?谢谢!

0 个答案:

没有答案