We Are Going To Discuss About Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test. So lets Start this Java Article.
Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
- Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
When the Spring Boot starts, it scans the classpath from the top to the bottom of the project to find the config file. Your config is under another files and that is a reason of the problem. Move you config upper to the monolith package and everything gonna be fine.
- Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
When the Spring Boot starts, it scans the classpath from the top to the bottom of the project to find the config file. Your config is under another files and that is a reason of the problem. Move you config upper to the monolith package and everything gonna be fine.
Solution 1
src/test/java
packages and src/main/java
packages should match.
I had same issue where
- my
src/main/java
packages were starting with com.comp.example but src/test/java
packages were starting with com.sample.example
Because of this spring boot application was not able to pickup the configuration of the application, which it picks up from @SpringBootApplication
class.
So test case should fall under the same packages where @SpringBootApplication
in src/main/java
is written.
Original Author Saurabh Parmar Of This Content
Solution 2
When the Spring Boot starts, it scans the classpath from the top to the bottom of the project to find the config file. Your config is under another files and that is a reason of the problem. Move you config upper to the monolith package and everything gonna be fine.
Original Author Yuriy Tsarkov Of This Content
Solution 3
@SpringBootTest
has a parameter named classes
. It accepts an array of classes for configuration. Add the class for the config file to it, for example:
@SpringBootTest(classes={com.lapots.game.monolith.web.GrandJourneyMonolithApplication.class})
Original Author downeyt Of This Content
Solution 4
Original Author pankaj pundir Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.