解决办法的参考来源:
https://www.cnblogs.com/shea/p/8693202.html
https://www.cnblogs.com/shea/p/8693202.html
1、我的问题
报错日志显示:
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
控制台输出


Test ignored.
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
// 警告:你的应用上下文可能没有启动,因为你将注解添加到了默认的package上面了
2、原因
我的默认路径:将APP启动类直接放在java包下了,这是有问题的。

3、解决办法
方法1:在main/java下建个包,将Application文件放进去:

方法2:在Application类上面加@ComponentScan注解,指定要扫描的。(这种方法我还没试过)
@SpringBootApplication
@EnableEurekaClient
@ComponentScan(basePackageClasses = TestClass.class )
public class ClientDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ClientDemoApplication.class, args);
}
}

博客主要讲述了Spring Boot开发中遇到的问题。报错日志显示在控制台输出,原因是将APP启动类直接放在java包下。解决办法有两种,一是在main/java下建包并放入Application文件,二是在Application类上加@ComponentScan注解指定扫描范围,第二种方法作者未尝试。


被折叠的 条评论
为什么被折叠?



