一、打开Idea
二、配置
- 选择Spring Initializr
- 填写你的项目名称
- 修改你的项目地址
- 选择java8,使用jdk1.8版本
下一步
点击Finish完成
三、添加SpringMVC模块依赖
org.springframework.boot
spring-boot-starter-web
四、添加项目端口
application.properties文件中:
server.port=8888
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class IndexController {
@GetMapping("/index")
public String index(){
return "index";
}
}
七、启动项目并请求接口
http://localhost:8888/index