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

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

对于需要从组织上级扩展的项目,您有什么建议(这是非常普遍的情况,甚至很多/大多数项目都会发布到Maven中心,具体取决于它们来自哪个feeder仓库)。大多数构建工作都与创建可执行JAR(例如,运行嵌入式Tomcat / Jetty)有关。有一些方法可以构造事物,这样您就可以获取所有依赖关系而无需从父级扩展(类似于合成vs.继承)。但是您无法以这种方式获得构建内容。

因此,最好将所有spring-boot父pom包含在所需的父POM内,或者仅在项目POM文件中具有POM依赖项。

还有其他选择吗?



青春有我
浏览 686回答 3
3回答

慕丝7291255

您可以像使用“ bom”一样使用spring-boot-starter-parent(请参阅Spring和Jersey现在支持该功能的其他项目),并将其仅包含在scope = import的依赖项管理部分中。这样您将获得很多收益使用它的好处(即依赖项管理),而无需替换实际父项中的设置。它做的其他2件事是定义属性负载以快速设置要覆盖的依赖项版本使用默认配置(主要是Spring Boot maven插件)配置一些插件。因此,如果您使用自己的父母,那么您将必须手动执行这些操作。Spring Boot文档中提供的示例:<dependencyManagement>&nbsp; &nbsp; <dependencies>&nbsp; &nbsp; &nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <!-- Import dependency management from Spring Boot -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.springframework.boot</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>spring-boot-dependencies</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>2.1.3.RELEASE</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <type>pom</type>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <scope>import</scope>&nbsp; &nbsp; &nbsp; &nbsp; </dependency>&nbsp; &nbsp; </dependencies></dependencyManagement>

汪汪一只猫

根据Surasin Tancharoen的回答,您可能还需要定义maven surefire插件&nbsp; &nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.maven.plugins</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>maven-surefire-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>${maven-surefire-plugin.version}</version>&nbsp; &nbsp; &nbsp; &nbsp; </plugin>并可能包括故障快速插件&nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.maven.plugins</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>maven-failsafe-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>${maven-failsafe-plugin.version}</version>&nbsp; &nbsp; &nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>integration-test</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>verify</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; </executions>&nbsp; &nbsp; </plugin>分享编辑
打开App,查看更多内容
随时随地看视频慕课网APP