Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
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.
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.
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})
Solution 4:
In my case this was due to some [move|copy/paste] of classes. For some, the package
clause was either [not updated correctly|not present|correct, but somehow the changes were not picked up].
Anyway, review your project packaging.