用idea新建springboot项目遇到的@Restcontroller不能导入的问题
生活随笔
收集整理的這篇文章主要介紹了
用idea新建springboot项目遇到的@Restcontroller不能导入的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我個人的解決方法如下:
1.springboot默認有
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency> </dependencies>這時要引入Web模塊,需在pom.xml添加spring-boot-starter-web模塊
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId> </dependency>2. 然后用maven reimport 更新下依賴包。
3.Invalidate and restart 重啟下
(1)點擊File–>Invalidate Caches/Restart,進入重啟窗口
(2)選擇自己所需要的重啟方式,四個按鈕,一共三種重啟方式
按鈕說明:
Invalidate and Restart:清空緩存并重啟。
Invalidate:?清除緩存,下次打開重啟。
Cancel:?取消。
Just Restart:?重啟
4.使用intellj idea,這時重啟后的編輯器會自動提示要按alt+enter。如果不提示,就手動引入
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;此時就ok了。
總結
以上是生活随笔為你收集整理的用idea新建springboot项目遇到的@Restcontroller不能导入的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ElementUI+Java实现搜索提示
- 下一篇: using 和typedef区别