spring boot中不能识别RestController的原因
我个人的解决方法:
========================================
没有这个注解:
少了依赖:
这样就有了:
============================================
1.springboot默认有
这时要引入Web模块,需在pom.xml添加spring-boot-starter-web模块
2. 然后用maven reimport 更新下依赖包。
3.Invalidate and restart 重启下。
4.我使用intellj idea,这时重启后的编辑器会自动提示要按alt+enter。如果不提示,就手动引入
应该就好了。
希望新手不要被再调入这个坑了。严重打击新手对java和spring学习的动力。
参考:
https://www.cnblogs.com/dogma96828/p/10108386.html