'How can I have 2 different working AuditorAware implementations on Spring Boot?
I have two different datasources on my Spring Boot 2.6 project, but I'd like to have two different AuditorAware implementations (one for each datasource).
As you know, you can only have one @EnableJpaAuditing annotation in the project, and in there you can make reference to only one AuditorAware bean:
@EnableJpaAuditing(auditorAwareRef="auditorAwareImplBean")
I need to have for one datasource DB entities a getCurrentAuditor() implementation that returns a name and for the second datasource an getCurrentAuditor() that returns an email.
I've tried creating another AuditorAware implementation and then setting the @EnableJpaAuditing annotation on each Datasource config, but I get a duplicated bean error (you can only have one @EnableJpaAuditing per project.
The audit fields are on a separate @MappedSupeclass from all my entities, and the audited fields are annotated with @Createdby and @LastModifiedBy.
I don't want to change this approach (changing entities and so). Is there any approach you recommend?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
