java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Context


issue the following error when unit testing

java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Context

There are two reasons for this problem

1. See if there is a primary startup class

2. As shown in the figure above, if the main boot class already exists, the error may be in the test directory and will be reported if they are not in the same directory.
Put it in the same directory and the problem is solved.

Read More: