1.starter
一个starter就是一个开发场景的支持(一个starter不仅包含所需依赖,还包含了其所需的对应的配置)
SpringBoot为我们提供了简化企业级开发绝大多数场景的支持(提供了多个starter),我们在进行项目开发的过程中只需引入对应的starter(创建SpringBoot应用时可选择),相关的依赖和配置就会被内置待项目中(消除人工配置)
一个starter配置表示的不是一个依赖,而是某种开发环境所需的一组依赖
Spring Web --- spring-boot-starter-web
MyBatis Framework --- mybatis-spring-boot-starter
2.SpringBoot应用的pom文件
2.1 基于Spring官方服务器创建的SpringBoot应用
-
继承spring-boot-starter-parent.pom
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- SpringBoot应用中的pom 继承了spring-boot-starter-parent.pom --> <!-- spring-boot-starter-parent.pom又继承了spring-boot-dependencies.pom--> <!-- 在spring-boot-dependencies.pom已经对主流的框架的版本进行了声明 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.4</version> <relativePath/> </parent> </project>
-
引入了maven对springboot应用支持的插件 spring-boot
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.qfedu.springboot.demo.SpringbootDemo1Application</mainClass>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
2.2 基于ali服务器创建的SpringBoot应用
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.qfedu</groupId>
<artifactId>springboot-demo2</artifactId>
<version>1.0.0</version>
<name>springboot-demo2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!--SpringBoot引用的pom没有继承spring-boot-starter-parent.pom,因此版本需要在当前pom中进行定义 -->
<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
</properties>
<build>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.7.RELEASE</version>
<configuration>
<mainClass>com.qfedu.springboot.demo2.SpringbootDemo2Application</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>