Skip to content
Advertisement

Failed to load ApplicationContext for a java based config test

I want to test the Repository-Layer of my SpringBootApplication, but it fails to load application context. By the way I am using Java 17.

Here is the error

JavaScript

Here is My simple test class.

JavaScript

Here is the application.properties file

JavaScript

And finally here is my pom.xml

JavaScript

Configuration for webclient bean

JavaScript

I checked out different Spring-boot-test annotations like @SpringBootTest, but nothing changed. Is there anyone out there who has the same issue or a solution? If you need further information/ code snippets / error stacks please contact me. thanks

Advertisement

Answer

I need to move @ComponentScan annotation from ApiApplication.java to Configuration.java file, as it is described in spring-boot documentation, and that solved my problem.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement