springboot无法识别controller
springboot项目的一个模块中,无法识别controller ,断点和日志都进不去。
总是提示路径不对:
找了半天,终于发现了一个问题:
目录结构有问题,SearchApplication的路径是
com.tensquare.search.SearchApplication
而ArticleController 的路径是:
com.tensquare.controller.ArticleController
发现了没,很低级的错误,根本扫描不到。
而springboot项目加载的时候@SpringBootApplication注解会去扫描当前目录以及子目录的文件,修改路径即可。其实idea也给出了提示
ArticleController是灰色的,代表没有扫描到,路径修改对了就会变成白色的高亮显示