I'm testing my Spring application with JUnit, however the error is occurring after putting the annotation @EnableJpaRepositories
:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
Configuration class:
@SpringBootApplication
@ComponentScan
@EnableJpaRepositories
public class ExampleApplication {
public static void main(String[] args) {
SpringApplication.run(ExampleApplication.class, args);
}
}
Removing this annotation returns the problem that does not find a dependency for the repository interface.
Obs: The application starts normally, this problem occurs when running the tests, both with Gradle and JUnit.