使用IDEA2018创建第一个SpringBoot项目.
第一个:
第二个:注意Artifact不能出现大写英文字母,这里使用“-”作为多个单词的分隔。
第三个:
第四个:
点击finish,项目创建完毕。
项目结构如下:
编写第一个Controller:
package com.linglib.myproject.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@RequestMapping("/test")
public String test(){
return "test!";
}
}
启动项目,正常会启动成功。我这里报错,原因是8080端口被占用:
在properties文件设置端口使用8081
重新启动项目,在浏览器输入http://localhost:8081/test