在Spring Boot应用程序中,我想测试(JUnit 5)启用审计的持久性层(@EnableJpaAuditing)。我使用 Liquibase 来设置 H2 db 和 Hibernate 作为 JPA 实现。
@Configuration
//@EnableTransactionManagement
@EnableJpaAuditing
//@EnableJpaRepositories
public class MyPersistenceConfig {
}
我的实体具有以下字段:
@CreatedDate
@Column(name = "CREATED_AT", updatable = false)
private Instant createdAt;
@CreatedBy
@Column(name = "CREATED_BY", updatable = false)
private String createdBy;
@CreatedDate
@Column(name = "LAST_MODIFIED_AT")
private Instant lastModifiedAt;
@CreatedBy
@Column(name = "LAST_MODIFIED_BY")
private String lastModifiedBy;
我有以下依赖关系:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<scope>runtime</scope>
<!--<scope>test</scope>-->
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
慕田峪4524236
月关宝盒
相关分类