不使用 Spring Boot 作为父 pom 会有什么后果?

iMa*_*kre 5 maven spring-boot

我有一个多模块 Maven 项目,它共享一个公共的父 pom.xml。其中一些模块将使用 Spring Boot,但有些则不会。我不想使用 Spring Boot 作为我的父 pom 的父项,并且在不使用它们的模块中存在不必要的依赖项。

不使用Spring Boot父pom会有什么后果?一切都仍然可以与所有自动配置的优点一起使用吗?我正在考虑以下解决方案,将其放入我的父 pom 中作为替代方案

<dependencyManagement>
    <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>1.4.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)

但我对所有这些 Maven 东西和 Spring Boot 都很陌生,所以我不希望出现任何意想不到的后果,也不希望以任何方式削弱 Spring Boot 的功能。有人可以解释一下,如果我这样做,我会失去什么(如果有的话)?谢谢!

Rol*_*der 3

参考指南解释了如何在没有 Spring Boot 的情况下使用 Spring Bootspring-boot-starter-parent以及会发生什么。这个答案spring-boot-starter-parent也解释了和之间的区别spring-boot-dependencies

摘要:通过这两种方式,您可以获得所有 Spring Boot 组件和第三方库的强大依赖管理。还spring-boot-starter-parent配置一些 Maven 插件,例如spring-boot-maven-plugin运行mvn spring-boot:run.