開發環境:
前提條件:已安裝以上軟件并配置好jdk和maven的環境變量
創建步驟:
點擊坐上角file ---》選擇new ---》點擊project... 如下圖所示:
點擊左邊Spring Initializr ---》 右上角新建jdk(若有則不需要) ---》 點擊next 如下圖所示:
看需求修改下圖中的信息后點擊next(可以直接使用默認)
點擊左邊的Web ---》 選中中間列的Web ---》 點擊next 如下圖所示:
輸入項目名稱和保存路徑 --- 》點擊finish
創建的項目如下圖所示:
創建HelloController類,代碼如下所示:
package com.example.demo.controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController@RequestMapping("/hello")public class HelloController { @RequestMapping("/say") public String sayHello() { return "hello world"; }}
執行DemoApplication中main方法后訪問http://localhost:8080/hello/say 頁面如下所示:
總結
以上所述是小編給大家介紹的Intellij IDEA創建spring-boot項目的圖文教程,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!
新聞熱點
疑難解答
圖片精選