参考资料:html
http://www.mamicode.com/info-detail-2101273.htmljava
http://www.javashuo.com/article/p-emexztit-be.htmlspa
错误提示:.net
** WARNING ** : Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
// 警告:你的应用上下文可能没有启动,由于你将注解添加到了默认的package上面了
缘由解析:code
SpringBoot在写启动类的时候若是不使用@ComponentScan指明对象扫描范围,默认指扫描当前启动类所在的包里的对象,若是当前启动类没有包,则在启动时会报错:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package错误。 由于启动类不能直接放在main/java文件夹下,必需要建一个包把它放进去或者使用@ComponentScan指明要扫描的包。
解决方法:htm
方法一:在main/java下建个包,将Application文件放进去;对象
方法二:在Application类上面加@ComponentScan注解,指定要扫描的包,以下: blog
@SpringBootApplication @EnableEurekaClient @ComponentScan(basePackageClasses = TestClass.class ) public class ClientDemoApplication { public static void main(String[] args) { SpringApplication.run(ClientDemoApplication.class, args); } }
@ComponentScan(basePackageClasses=要扫描类.class所在位置的包)-意思是要扫描哪一个类所在的包get