在以maven方式创建Spring Boot项目之前,需要先确保自己的Maven并配置好环境变量,并且在ideal中关联好maven环境。
参考文章:Maven详解(简介-作用-下载-安装-环境变量配置-配置文件说明-IDEA上配置Maven)





目前这还只是一个普通的maven项目,还不是springboot项目
在pom.xml文件中添加
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/>
</parent>

继承父类的作用
当添加了spring-boot-starter-parent依赖之后,这个项目就是springboot项目了,项目中就可以直接继承父依赖中合理的默认值。
比如继承父项目可以提供以下功能:
a.设置Java 1.8作为默认的编译器;
b.UTF-8编码;
c.允许省略常见依赖的版本标签。
d.识别资源过滤 例如,打包的时候把 src/main/resources 下所有文件都打包到包中。
<resource>
<directory>src/main/resourcesdirectory>
<includes>
<include>**/*.*include>
includes>
<filtering>truefiltering>
resource>
e.识别插件的配置
比如 exec plugin, surefire, Git commit ID, shade
能够识别 application.properties 和 application.yml 类型的文件,同时也能支持 profile-specific 类型的文件(如: application-foo.properties and application-foo.yml,这个功能可以更好的配置不同生产环境下的配置文件)。
pom.xml文件中添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
plugin>
plugins>
build>

添加web模块 才能运行web类型
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starterartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-webartifactId>
dependency>
dependencies>




