当前位置: 代码迷 >> 综合 >> spring-boot-starter-parent和spring-boot-dependencies
  详细解决方案

spring-boot-starter-parent和spring-boot-dependencies

热度:53   发布时间:2023-12-26 04:45:48.0

如何创建一个SpringBoot项目,SpringBoot的依赖引入都是基于starter的,通常创建一个SpringBoot项目都是通过继承关系指定pom文件中的parent

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.2.5.RELEASE</version><relativePath/> <!-- lookup parent from repository -->
</parent>

然后使用<dependency></dependency>标签来引入相应的依赖,比如常用的lombok

<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional>
</dependency>

除了继承spring-boot-starter-parent的方式外,还有一种方式那就是通过<dependency/>引入spring-boot-dependencies相关依赖。

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>${spring.boot.version}</version><type>pom</type><scope>import</scope>
</dependency>

在使用maven创建SpringCloud聚合项目时,通常在父pom文件中通过spring-boot-dependencies引入SpringBoot相关依赖,然后子项目使用parent标签来继承父项目,方便依赖管理。

  相关解决方案