Auditing

要激活审计,请将 @EnableJdbcAuditing 添加到你的配置中,如下面的示例所示:

In order to activate auditing, add @EnableJdbcAuditing to your configuration, as the following example shows:

Activating auditing with Java configuration
@Configuration
@EnableJdbcAuditing
class Config {

  @Bean
  AuditorAware<AuditableUser> auditorProvider() {
    return new AuditorAwareImpl();
  }
}

如果你向 ApplicationContext 公开 AuditorAware 类型的 bean,审计基础架构会自动获取它并使用它来确定要在域类型上设置的当前用户。如果你在 ApplicationContext 中注册了多个实现,则可以通过显式设置 @EnableJdbcAuditingauditorAwareRef 属性来选择要使用的一个。

If you expose a bean of type AuditorAware to the ApplicationContext, the auditing infrastructure automatically picks it up and uses it to determine the current user to be set on domain types. If you have multiple implementations registered in the ApplicationContext, you can select the one to be used by explicitly setting the auditorAwareRef attribute of @EnableJdbcAuditing.