Spring-Boot學習(一)
阿新 • • 發佈:2017-11-27
圖片 public ram turn tps bind 實現 file clas
入門實例 - HelloWorld
File > New > Spring Starter Project
項目創建完成:
這樣就完成了項目的創建,下面我們創建一個 HelloController.java
package com.example.demo; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/hello") public class HelloController { static { System.out.println("HelloController was on line!"); } @RequestMapping("/SpringBoot") public String hello() { return "hello Spring Boot"; } }
在瀏覽器輸入 http://localhost:8080/bootdemo/hello/SpringBoot
輸出 hello Spring Boot
實現成功!
Spring-Boot學習(一)