Spring Boot启动失败 BeanDefinitionSt

2020-02-14  本文已影响0人  weifansym

初学Spring Boot,启动时失败:

** WARNING ** :Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL

CSDN小伙伴提出的解决方案:


查了半天终于才stack overflow上看到了解决方案,链接如下:stack overflow
是因为application.java 文件不能直接放在main/java文件夹下,必须要建一个包把他放进去

官方文档有一小段说明:

14.1 Using the “default” Package
When a class does not include a package declaration, it is considered to be in the “default package”. The use of the “default package” is generally discouraged and should be avoided. It can cause particular problems for Spring Boot applications that use the @ComponentScan, @EntityScan, or @SpringBootApplicationannotations, since every class from every jar is read.

上一篇 下一篇

猜你喜欢

热点阅读