SpringBoot —— helloword
阿新 • • 發佈:2018-12-16
1、建立專案選擇 Spring Initializr
2、新增web依賴
3、填寫好專案名稱和專案位置, 漫長等待後,初始化完成如下圖
4、執行mian測試如下
5、application.properties中配置埠和上下文路徑
server.port=8080
server.servlet.context-path=/springboot
6、編寫controller
package com.etc.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class HelloController { @RequestMapping("/hello") @ResponseBody public String hello(){ return "Hello, Spring Boot"; } }
6、測試