How can I do the same as: <jpa:auditing auditor-aware-ref="yourAuditorAwarebean" />
programmatically in a @Configuration
class?
Is the spring xml configuration mandatory to do this?
Java Config for auditing is now supported since Spring Data JPA 1.5 (link to documentation)
Replace the <jpa:auditing auditor-aware-ref="yourAuditorAwarebean" />
with the @EnableJpaAuditing
annotation on any of your configuration class.
E.g:
@Configuration
@EnableJpaAuditing
class Config {
@Bean
public AuditorAware<AuditableUser> yourAuditorAwarebean() {
return new YourAuditorAwareImpl();
}
}