I have the following Main Class.
@EnableJpaAuditing
@SpringBootApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBea
Move the @Enable*
annotations to a dedicated @Configuration
class. This is also explained in the Spring Boot Reference Guide in the special section User Configuration and Slicing and noted here.
Your main class should only have the @SpringBootApplication
annotation. Then create a specific @Configuration
annotated class with the @Enable
stuff on it.
@SpringBootApplication
public class SampleApplication {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
}
And a specific configuration for JPA
@Configuration
@EnableJpaAuditing
@EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)
public class JpaEnversConfiguration {}
Now you can safely use @WebMvcTest
without it complaining about JPA.