【问题标题】:What are the consequences of not using Spring Boot as the parent pom?不使用 Spring Boot 作为父 pom 会有什么后果?
【发布时间】:2017-11-04 07:51:49
【问题描述】:

我有一个多模块 Maven 项目,它共享一个共同的父 pom。其中一些模块将使用 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>

但我对所有这些 Maven 内容和 Spring Boot 还是很陌生,所以我不希望有任何意外后果或以任何方式取消 Spring Boot 的功能。有人可以解释如果我这样做会失去什么(如果有的话)吗?谢谢!

【问题讨论】:

    标签: maven spring-boot


    【解决方案1】:

    Reference Guide 解释了如何在没有spring-boot-starter-parent 的情况下使用 Spring Boot 以及会发生什么。 This answer 也解释了spring-boot-starter-parentspring-boot-dependencies 的区别。

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

    【讨论】:

      猜你喜欢
      • 2014-10-04
      • 2014-02-14
      • 2014-11-05
      • 2017-05-05
      • 2020-05-23
      • 2018-04-09
      • 2016-08-20
      相关资源
      最近更新 更多