为了账号安全,请及时绑定邮箱和手机立即绑定

Spring Boot-如果您已经有父pom,则为父pom

Spring Boot-如果您已经有父pom,则为父pom

青春有我 2019-11-25 11:18:43
是否有特定的推荐方法将spring-boot父pom包含在已经具有所需父POM的项目中?对于需要从组织上级扩展的项目,您有什么建议(这是非常普遍的情况,甚至很多/大多数项目都会发布到Maven中心,具体取决于它们来自哪个feeder仓库)。大多数构建工作都与创建可执行JAR(例如,运行嵌入式Tomcat / Jetty)有关。有一些方法可以构造事物,这样您就可以获取所有依赖关系而无需从父级扩展(类似于合成vs.继承)。但是您无法以这种方式获得构建内容。因此,最好将所有spring-boot父pom包含在所需的父POM内,或者仅在项目POM文件中具有POM依赖项。还有其他选择吗?
查看完整描述

3 回答

?
慕丝7291255

TA贡献1859条经验 获得超6个赞

您可以像使用“ bom”一样使用spring-boot-starter-parent(请参阅Spring和Jersey现在支持该功能的其他项目),并将其仅包含在scope = import的依赖项管理部分中。这样您将获得很多收益使用它的好处(即依赖项管理),而无需替换实际父项中的设置。


它做的其他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>


查看完整回答
反对 回复 2019-11-25
?
汪汪一只猫

TA贡献1898条经验 获得超8个赞

根据Surasin Tancharoen的回答,您可能还需要定义maven surefire插件


        <plugin>

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-surefire-plugin</artifactId>

            <version>${maven-surefire-plugin.version}</version>

        </plugin>

并可能包括故障快速插件


    <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-failsafe-plugin</artifactId>

        <version>${maven-failsafe-plugin.version}</version>

        <executions>

            <execution>

                <goals>

                    <goal>integration-test</goal>

                    <goal>verify</goal>

                </goals>

            </execution>

        </executions>

    </plugin>

分享编辑


查看完整回答
反对 回复 2019-11-25
  • 3 回答
  • 0 关注
  • 677 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信