(1)File - New - Project - Spring Initializr
(2)Next,勾选Spring web依赖(该依赖会使用SpringMVC和tomcat容器),然后点击Create
(3)创建一个测试类,代码如下
package com.jxl.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class Test {
@RequestMapping("/test")
public String test(){
return "hello springboot";
}
}
(4)测试
启动项目,默认端口为8080,访问路径:http://localhost:8080/test
(5)项目结构说明
java包下的两个类说明:
Application:启动类
Test:测试类
resources包下目录说明:
static:静态资源文件夹
templates:模板页面文件夹
application.properties:全局配置文件
test包下用于写测试代码