Auditing

从 Spring Data R2DBC 1.2 开始,可以通过使用 @EnableR2dbcAuditing 注解来注释配置类来启用审核,如下例所示:

Since Spring Data R2DBC 1.2, auditing can be enabled by annotating a configuration class with the @EnableR2dbcAuditing annotation, as the following example shows:

Activating auditing using JavaConfig
@Configuration
@EnableR2dbcAuditing
class Config {

  @Bean
  public ReactiveAuditorAware<AuditableUser> myAuditorProvider() {
      return new AuditorAwareImpl();
  }
}

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

If you expose a bean of type ReactiveAuditorAware to the ApplicationContext, the auditing infrastructure picks it up automatically 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 @EnableR2dbcAuditing.