Spring Boot - 当您已经拥有父 pom 时的父 pom [英] Spring Boot - parent pom when you already have a parent pom

查看:39
本文介绍了Spring Boot - 当您已经拥有父 pom 时的父 pom的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有特定的推荐方法可以将 spring-boot 父 pom 包含到已经具有所需父 POM 的项目中?

Is there a specific recommended approach to the inclusion of the spring-boot parent pom into projects that already have a required parent POM?

对于需要从组织父级扩展的项目,您有什么建议(这是非常常见的,甚至许多/大多数项目都根据它们来自的馈送存储库发布到 Maven 中心).大多数构建内容与创建可执行 JAR(例如运行嵌入式 Tomcat/Jetty)有关.有多种方法可以构建事物,以便您无需从父级扩展即可获得所有依赖项(类似于组合与继承).但是,您无法通过这种方式获得构建内容.

What do you recommend for projects that need to extend from an organizational parent (this is extremely common and even something many/most projects published to Maven central depending on the feeder repos they come from). Most of the build stuff is related to creating executable JARs (e.g. running embedded Tomcat/Jetty). There are ways to structure things so that you can get all the dependencies without extending from a parent (similar to composition vs. inheritance). You can't get a build stuff that way though.

因此,最好将所有 spring-boot 父 pom 包含在所需的父 POM 中,还是只在项目 POM 文件中包含 POM 依赖项.

So is it preferable to include all of the spring-boot parent pom inside of the required parent POM or to simply have a POM dependency within the project POM file.

其他选择?

TIA,

斯科特

推荐答案

你可以像bom"一样使用 spring-boot-starter-parent (cf Spring 和 Jersey 其他现在支持此功能的项目),并包含它仅在具有 scope=import 的依赖项管理部分中.这样您就可以获得使用它的很多好处(即依赖项管理),而无需替换实际父项中的设置.

You can use the spring-boot-starter-parent like a "bom" (c.f. Spring and Jersey other projects that support this feature now), and include it only in the dependency management section with scope=import.That way you get a lot of the benefits of using it (i.e. dependency management) without replacing the settings in your actual parent.

它所做的另外两件事是

  1. 定义一组属性以快速设置要覆盖的依赖项版本
  2. 使用默认配置配置一些插件(主要是Spring Boot maven插件).因此,如果您使用自己的父级,则必须手动执行这些操作.

Spring Boot 文档:

<dependencyManagement>
    <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.3.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

这篇关于Spring Boot - 当您已经拥有父 pom 时的父 pom的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆