After you create your Spring boot project and when you write your first MockMvc test cases, you may land into the below error if the packages are not of same level.
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
at org.springframework.util.Assert.state(Assert.java:76)
Solution:
Spring MVC boot application and the Test code should be in same package level
Below – Main application DemoApplication.java and HelloControllerTest.java should be in same package structure
com.rajesh.demo
Let me know if you still face issues.
Comments
Post a Comment