import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackageClasses ={TestConfiguration.class})
public class TestApp {
}
然后您的单元测试应该指定先前创建的测试类
@SpringBootTest(classes = TestApp.class)
public class UnitTestClass {
}