从父型POM覆盖Spring-boot版本



我有多个弹簧项目,它们都具有相同的自定义父pom,它们都从中继承了弹簧启动版本(1.5.18.Release(。只有一个儿童项目需要更新为2.1.4.的版本,但是当我导入Spring-boot依赖性时,儿童项目中的弹簧启动依赖性仍然保持在1.5.18.Release版本中。

自定义父母pom:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.18.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>services</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Services :: Parent</name>
<description>Parent Project for Services</description>

儿童POM:

<parent>
    <artifactId>services</artifactId>
    <groupId>com.example</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../services/pom.xml</relativePath>
</parent>
<dependencyManagement>
    <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.4.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

您必须将父级更新为 2.1.4.release。这是因为如果孩子和父母不同步,可能会有很多发展问题。提示:您可以删除儿童依赖性中的版本标签。

spring-boot-starter-parent不仅定义依赖项,还可以配置插件和船只属性。由于您正在从Spring Boot 1.5.x升级到Spring Boot 2.x,因此很可能仅仅是颠簸版本,所以主要版本之间存在不兼容的变化。Spring Boot 1.5.x是Java 6 ,但Spring Boot 2.x是Java 8 。

您应该将spring-boot-starter-parent-2.1.4.RELEASE用作孩子pom.xml中的父母。您当前的方法正在修补,关注Spring Boot文档并将子模块设置为适当的Spring Boot 2.x模块,否则您将浪费大量时间调试由部分设置引起的问题。

最新更新