(前提条件:安装好IntellJ IDEA,maven)
1.新建Module或project
2.选择Spring Initializr—URL(https://start.spring.io/)
3.填写project Metadata
4.选择所需依赖(如搭建web项目,选择web)
5.项目结构
6.设置端口(默认8080)
7.控制器controller
@RestController
@RequestMapping(value = "/spring")
public class Test {
@RequestMapping(value = "/test",method = RequestMethod.GET)
public String testSpringBoot(){
return "Spring Boot 测试成功!";
}
}
8.运行浏览器输入地址(http://localhost:8081/spring/test)