Spring Data Rest: RepositoryEventHandler methods not invoked

前端 未结 2 479
清歌不尽
清歌不尽 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.

提交回复
热议问题