spring-projects / spring-projects/spring-data-rest

@RepositoryEventHandler isn't work

Open
#119 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.