1. 新建普通maven工程
2. 在pom.xml中添加父
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
此处需要注意artifactId
的内容不能错:spring-boot-starter-parent
(刚开始写成了spring-boot-start
-parent,导致一直报错…)
PS:如果写正确了还是报错,可能是镜像源的问题,可以更换为阿里云镜像
3. 导入web启动依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
</dependencies>
4.创建引导类MySpringBootApplication
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//添加该注解,表明这个是Springboot的引导类
@SpringBootApplication
public class MySpringBootApplication {
public static void main(String[] args