您必须将所有特定于区域的配置(例如
@ComponentScan和
@EnableMongoRepositories)移动到单独的
@Configuration文件中。重要的是不要用特定于应用程序功能特定区域的配置设置来乱扔应用程序的主类。
更多信息:https : //docs.spring.io/spring-
boot/docs/2.0.3.RELEASE/reference/htmlsingle/#boot-features-testing-spring-
boot-applications-testing-user-configuration



