spring-projects / spring-projects/spring-modulith
Adding `spring-boot-starter-data-jpa` dependency stops `@ApplicationModuleListener` receiving events
Open
@odrotbohm is already working on this.
Since Jan 29, 2024.
in: event publication registry
meta: waiting for feedback
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
the following snippet works until I add the spring-boot-starter-data-jpa dependency.
@EnableScheduling
@SpringBootApplication
public class DemoApplication {
private ApplicationEventPublisher publisher;
public DemoApplication(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@ApplicationModuleListener
public void onCustomEvent(CustomEvent event) {
System.out.println("Event received!");
}
@Scheduled(timeUnit = TimeUnit.SECONDS, fixedRate = 5)
public void fireEvents() {
System.out.println("firing event");
publisher.publishEvent(new CustomEvent());
}
record CustomEvent() {}
}
Is there something that I am missing ?
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.
Assessment
This issue has not been assessed yet.