此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Data Relational 3.4.5! |
Auditing
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();
}
}
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
.