spring boot中不能识别RestController的原因

最近正在学习Spring boot

在跟着网上的教程试着建立自己第一个Spring boot项目时,遇到了这个问题

 

spring boot中不能识别RestController的原因_第1张图片

而网上给出的例子及解决方案中,只提到了需要pom.xml中增加引入web模块,即如下代码


org.springframework.boot
spring-boot-starter-web

但加了这段之后仍不能解决问题。

在网上找了很久,才发现一个外文的网站求助帖子中提到RestController不能直接使用,需要加上路径"org.springframework.web.bind.annotation.",即

spring boot中不能识别RestController的原因_第2张图片


问题解决了

我并不清楚里面的原理,只是记录下来以备忘,也希望能帮到别人。


你可能感兴趣的:(spring boot中不能识别RestController的原因)