SpringBoot——场景启动器(starter)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/rubulai/article/details/81106766

一、版本控制器:

SpringBoot应用的pom.xml中引入了一个父项目parent

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.0.3.RELEASE</version>
</parent>

该父项目的parent:相当于SpringBoot的版本仲裁中心

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-dependencies</artifactId>
	<version>2.0.3.RELEASE</version>
	<relativePath>../../spring-boot-dependencies</relativePath>
</parent>

其中有个properties标签指定了一些依赖的版本:解决了一些版本冲突的问题,有了它我们在导入依赖时默认不需要写版本号,但是没有在此处声明版本号的依赖依然需要写明版本

<properties>
	<activemq.version>5.15.4</activemq.version>
	<antlr2.version>2.7.7</antlr2.version>
	<appengine-sdk.version>1.9.64</appengine-sdk.version>
	<artemis.version>2.4.0</artemis.version>
	<aspectj.version>1.8.13</aspectj.version>
	<assertj.version>3.9.1</assertj.version>
	...
</properties>

二、场景启动器

SpringBoot应用的pom.xml中还引入了一个依赖:spring-boot-starter-web

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>

spring-boot-starter:SpringBoot的场景启动器

spring-boot-starter-web:帮我们导入了web模块正常运行所依赖的组件,其中就包含spring-boot-starter

<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter</artifactId>
		<version>2.0.3.RELEASE</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-json</artifactId>
		<version>2.0.3.RELEASE</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-tomcat</artifactId>
		<version>2.0.3.RELEASE</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.hibernate.validator</groupId>
		<artifactId>hibernate-validator</artifactId>
		<version>6.0.10.Final</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
		<version>5.0.7.RELEASE</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-webmvc</artifactId>
		<version>5.0.7.RELEASE</version>
		<scope>compile</scope>
	</dependency>
</dependencies>

SpringBoot将所有的功能场景都抽取出来,做成一个个的场景启动器(starter)——就是一系列依赖的组合,在项目中我们可以通过导入这些starters进行相关场景的开发

每一个场景启动器都会引入spring-boot-starter

猜你喜欢

转载自blog.csdn.net/rubulai/article/details/81106766