Spring Boot 學習筆記(二)
阿新 • • 發佈:2017-10-04
imp family framework ima pri spa cal bin ges
新建Srping Boot 項目
以下是項目結構
由於Srping Boot內置Tomcat,所以不需要配置Tomcat就可以直接運行。
HelloWorldApplication是啟動類,我們右擊Run As 選擇 Spring Boot app。
項目運行好之後
在瀏覽器輸入:http://localhost:8080/
看到這個頁面項目就算啟動好了。
然後新建一個HelloWorldController類
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
@RequestMapping("/helloWorld")
public String say() {
return "HelloWorld";
}
}
然後我們重新啟動HelloWorldApplication類
請求 http://localhost:8080/helloworld
Spring Boot 學習筆記(二)