审计
为了启用审计功能,请在你的配置中添加 @EnableJdbcAuditing
,如下例所示:
@Configuration
@EnableJdbcAuditing
class Config {
@Bean
AuditorAware<AuditableUser> auditorProvider() {
return new AuditorAwareImpl();
}
}
如果你将类型为 AuditorAware
的 Bean 暴露给 ApplicationContext
,审计基础设施会自动获取它,并使用它来确定要设置在域类型上的当前用户。如果在 ApplicationContext
中注册了多个实现,你可以通过显式设置 @EnableJdbcAuditing
的 auditorAwareRef
属性来选择要使用的实现。