springboot 入門-Idea建立helloworld工程
阿新 • • 發佈:2018-12-28
一:準備環境
1.JDK環境:JDK1.8
開發環境:IDEA2018.3
二:建立IDEA專案工程
三:HelloWorld例項
-
目錄結構:
-
編寫controllor程式碼
package com.controller; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @EnableAutoConfiguration public class helloController { @RequestMapping("/hello") private String hello(){ return "Hello World!"; } }
-
注意!!!
DemoApplication 一定要放在包的最外層!!!否則出現以下錯誤!!!
四:專案啟動
兩種方式:
- application啟動
-
IDEA工具欄啟動
五:測試helloworld
開啟瀏覽器輸入: http://localhost:8080/hello