Spring Data Rest: RepositoryEventHandler methods not invoked

前端 未结 2 465
清歌不尽
清歌不尽 2020-12-05 08:16

I am trying to add a RepositoryEventHandler as described on Spring Data REST documentation to the REST repository shown below:

@RepositoryRestResource(collec         


        
相关标签:
2条回答
  • 2020-12-05 08:35

    Sometimes obvious mistakes go unnoticed.

    POST-ing a Spring Data REST resource, emits a BeforeCreateEvent. To catch this event, the method handleBeforeSave must be annotated with @HandleBeforeCreate instead of @HandleBeforeSave (the latter gets invoked on PUT and PATCH HTTP calls).

    Tests pass successfully on my (cleaned up) demo app now.

    0 讨论(0)
  • 2020-12-05 08:39

    How does your main Application class look like? Does it import the RepositoryRestMvcConfiguration as described in https://spring.io/guides/gs/accessing-data-rest/?

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