idea創建springboot項目
阿新 • • 發佈:2018-07-31
http init hello 使用 代碼 cal .html 一個 ont
??前面的博客有說到spring boot搭建見另一篇博文,其實那篇博文還沒寫,現在來填個坑。我們使用spring initializr來構建,idea和eclipse都支持這種方式,構建過程類似,這裏以idea為例,詳細記錄構建過程。
1.選擇spring initializr
next
2.設置參數
next
3.選擇依賴
??在這裏選擇spring boot版本和web依賴(忽略sql的依賴,如有需要點擊這裏,單獨將mybatis的整合),後面也可手動編輯pom文件修改增加刪除依賴
這裏我們選擇web搭建一個簡單的REST風格demo。然後next。
4.設置項目存放地址
這樣就成功構建了一個springboot項目。
5.測試
??現在新建一個controller包,包下新建一個HelloController,創建之後項目目錄結構如下:
HelloController代碼如下:
@RestController
@RequestMapping("/home")
public class HelloController{
@GetMapping("/hello")
public String sayHello(){
return "hello";
}
}
然後運行項目,訪問localhost:8080/home/hello即可看到hello字符串。
idea創建springboot項目