spring-projects / spring-projects/spring-data-rest
@RepositoryEventHandler isn't work
Open
Nobody has claimed this yet.
status: waiting-for-triage
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
UserEventHandler.JAVA
@RepositoryEventHandler(User.class)
public class UserEventHandler {
@HandleBeforeSave
public void handleBeforeSave(User user) {
System.out.println("**********handleBeforeSave***********");
}
@HandleAfterDelete
public void handleAfterDelete(User user) {
System.out.println("**********handleAfterDelete***********");
}
}
MyRepositoryRestMvcConfiguration.java
@Configuration
public class MyRepositoryRestMvcConfiguration extends RepositoryRestMvcConfiguration {
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource msgsrc = new ReloadableResourceBundleMessageSource();
msgsrc.setBasename("/WEB-INF/classes/ValidationMessages");
msgsrc.setFallbackToSystemLocale(false);
return msgsrc;
}
@Bean
UserEventHandler UserEventHandler() {
return new UserEventHandler();
}
}
How trigger it?need publish custom event in spring context?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with UserEventHandler.java and MyRepositoryRestMvcConfiguration.java, then trace how the registered @RepositoryEventHandler is discovered and how repository operations trigger events. Reproduce the example and determine whether publishing a custom Spring context event is required; done means the handler behavior and trigger path are confirmed or the missing configuration is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100