Search code examples
javaspring-bootjunit

Spring Boot JUnit Test Define BaseRepositoryTest for its related repository Failed to load ApplicationContext


I have a problem about defining baserepositorytest class for annotation extending from another class.

Here is the base repository test shown below.

@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@RunWith(SpringRunner.class)
public abstract class BaseRepositoryTests {
}

Here is the repository test shown below.

public class BookRepositoryTests extends BaseRepositoryTests {

}

I got this error shown below.

java.lang.IllegalStateException: Failed to load ApplicationContext

How can I fix it?


Solution

  • Here is the solution shown below.

    After clicking "invalidate caches" and restarting the Intellij IDEA, the issue disappeared.