spring boot注入jar包中的接口总是提示that could not be found

匿名用户1572018-02-06 14:57
@ComponentScan(basePackages = {"cn.studyjava"})

SpringBoot在写启动类的时候如果不使用@ComponentScan指明对象扫描范围,默认指扫描当前启动类所在的包里的对象,如果当前启动类没有包,则在启动时会报错:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package错误。
因为启动类不能直接放在main/java文件夹下,必须要建一个包把它放进去或者使用@ComponentScan指明要扫描的包。

评论

请登录后发表观点

暂无数据