pop.xml文件的配置可以分为三大组成部分。
一、继承:一个maven项目是不是Spring Boot项目,就看它的pop.xml文件是否继承了spring-boot-starter-parent启动器。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
二、依赖:根据不同应用场景导入不同场景的所依赖的启动器(jar包座标)。
Spring Boot项目所需的44个启动器总结在:https://blog.csdn.net/luqingshuai_eloong/article/details/106202718
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
三、插件:
① spring-boot-maven-plugin这个插件是Spring Boot项目必须的一个插件,在项目打包发布时能将项目依赖的所有jar包都打包到项目中,否则项目会缺少jar包。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>