Spring Boot @RepositoryEventHandler not invoked

前端 未结 1 893
情书的邮戳
情书的邮戳 2021-01-02 17:31

I\'ve got a @RepositoryEventHandler set up and it is not being invoked for some unknown reason.

@Component
@RepositoryEventHandler(User.class)
p         


        
相关标签:
1条回答
  • 2021-01-02 18:19

    There could be a couple of things going on.

    You're repo isn't annotated w/ @RestResource, but I'm guess that was just an oversight.

    I'm guessing the comments are correct and you're testing this through a unit test with an entry point that is not going through the REST API. The handlers only capture Repo events that are coming through that vector.

    If you want to capture any repo event, regardless of entry point, then you want to use a AbstractRepositoryEventListener

    The Spring Data Rest Events documentation covers this. Also see listening for repository events in spring boot.

    0 讨论(0)
提交回复
热议问题