一、在IDEA中新建项目,选择Spring Initializr ,然后next
二、填写项目名和包名
三、选择Web
四、选择项目路径
五、项目架构
六、编辑Hello SpringBoot
(1)新建一个java类:
(2)代码:
package com.dongtian.springboot_1.controller;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@RequestMapping("/hello")
public String helloSpringBoot(){
return "Hello SpringBoot";
}
}
(3)、打开浏览器访问:http://localhost:8080/hello,结果如下: