jpa的entry审查Auditing

We provide @CreatedBy, @LastModifiedBy to capture the user who created or modified the entity as well as @CreatedDate and @LastModifiedDate to capture the point in time this happened.

当使用@CreatedBy时会使用下用户名

@Component
public class SpringSecurityAuditorAware implements AuditorAware<String> {

@Override
    public String getCurrentAuditor() {

        return "shangzebei";
    }
}

如果类实现了AuditorAware程序就会自动使用此类的实例,如果有多个同时实现就可以通过@EnableJpaAuditing中auditorAwareRef指定

猜你喜欢

转载自blog.csdn.net/a917058965/article/details/79820508
JPA