解决办法的参考来源:
https://www.cnblogs.com/shea/p/8693202.htmlhttps://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);
}
}