spring-modulith
spring-modulith copied to clipboard
EnablePersistentDomainEvents annotation can't be used
Looks like EnablePersistentDomainEvents will select EventPublicationConfiguration for import and at the same time EventPublicationAutoConfiguration extends EventPublicationConfiguration so if you add EnablePersistentDomainEvents annotation then the application fails to start
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'eventPublicationRegistry', defined in class path resource [org/springframework/modulith/events/config/EventPublicationAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/modulith/events/config/EventPublicationConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Workaround for now seems to be to either enable overriding or just not using the annotation and manually importing your EventPublicationConfigurationExtension and EventSerializationConfigurationExtension implementations.
Can you elaborate on why you would want to use the annotation explicitly? It's a left-over from the times in which Spring Boot was not a mandatory dependency. There's no real use for that any more, except in our very own integration testing code.
Ah ok, I couldn't figure out a better way to use spring-modulith-events without other parts of modulith project.
Can you elaborate on what you were trying to do? spring-modulith-events is not an actual artifact but solely a parent project for the individual ones. I.e. it doesn't really make sense to want to use that one in particular.
Actual modules I added were
implementation 'org.springframework.modulith:spring-modulith-events-core'
implementation 'org.springframework.modulith:spring-modulith-events-jackson'
implementation 'org.springframework.modulith:spring-modulith-events-jdbc'
My goal is to use the persistent events logic in our modular monolith project without using full spring modulith
Just fyi not an issue for me personally anymore, since using full Modulith instead of events only is not an issue actually