搜索

此内容没有您所选择的语言版本。

Chapter 1. Migrating Spring Boot 2.5 applications to Spring Boot 2.7.18

download PDF

The Spring Boot BOM (Bill of Materials) that manages dependencies for Red Hat-supported components is not available from Red Hat support for Spring Boot 2.7 onward. To migrate applications that use the Spring Boot BOM for dependency management, you can remove the BOM from your application’s pom.xml file and then add the required dependencies with their versions in the pom.xml file.

The following procedure shows you how to update some of the commonly used dependencies for Red Hat components. For a complete list of dependencies, see the Supported Spring Boot configurations and integrations.

Prerequisites

  • You have a working Spring Boot application that uses the Spring Boot BOM.

Procedure

  1. Remove the Spring Boot BOM from the pom.xml file in your application.

    • If you use the BOM as a dependency in the <dependencyManagement> section of the pom.xml file, remove the following lines from the file:

      <project>
        ...
        <dependencyManagement>
          <dependencies>
            <dependency>
              <groupId>io.dekorate</groupId>
              <artifactId>dekorate-spring-bom</artifactId>
              <version>${dekorate.version}</version>
              <type>pom</type>
              <scope>import</scope>
            </dependency>
            <dependency>
            <dependency>
              <groupId>dev.snowdrop</groupId>
              <artifactId>snowdrop-dependencies</artifactId>
              <version>{version-spring-boot-bom}</version>
              <type>pom</type>
              <scope>import</scope>
            </dependency>
          </dependencies>
        </dependencyManagement>
        ...
      </project>
    • If you use the BOM as a parent BOM, remove the following lines from the file:

      <project>
        ...
        <parent>
          <groupId>dev.snowdrop</groupId>
          <artifactId>snowdrop-dependencies</artifactId>
          <version>{version-spring-boot-bom}</version>
        </parent>
        ...
      </project>
  2. Add management dependencies for Spring Boot and Dekorate. You can find the latest supported versions for the dependencies in Red Hat Runtimes: Component Details Overview.

    <dependencyManagement>
      ...
      <dependency>
        <groupId>io.dekorate</groupId>
        <artifactId>dekorate-spring-bom</artifactId>
        <version>${dekorate.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-dependencies</artifactId>
          <version>${spring-boot.version}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
      ...
    </dependencyManagement>
  3. Add versions in the Red Hat-supported components included as dependencies. You can find the latest supported versions for the dependencies in Red Hat Runtimes: Component Details Overview.

    <dependencies>
      ...
      <!-- Dekorate -->
      <dependency>
        <groupId>io.dekorate</groupId>
        <artifactId>openshift-spring-starter</artifactId>
        <version>${dekorate.version}</version>
      </dependency>
    
      <!-- Hibernate -->
      <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
          <exclusion>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jta_1.1_spec</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
    
      <!-- Hibernate Validator-->
      <dependency>
        <groupId>org.hibernate.validator</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>${hibernate-validator.version}</version>
      </dependency>
    
      <!-- Narayana -->
      <dependency>
        <groupId>org.jboss.narayana.jta</groupId>
        <artifactId>narayana-jta</artifactId>
        <version>${narayana.version}</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.narayana.jts</groupId>
        <artifactId>narayana-jts-integration</artifactId>
        <version>${narayana.version}</version>
       </dependency>
    
      <!-- RestEasy -->
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-spring-boot-starter</artifactId>
        <version>${resteasy-spring-boot-starter.version}</version>
       </dependency>
    
      <!-- Tomcat -->
      <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>${tomcat.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-el</artifactId>
        <version>${tomcat.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <version>${tomcat.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-websocket</artifactId>
        <version>${tomcat.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.tomcat</groupId>org.apache.tomcat
        <artifactId>tomcat-jdbc</artifactId>
        <version>${tomcat.version}</version>
      </dependency>
    
      <!-- Undertow -->
      <dependency>
        <groupId>io.undertow</groupId>
        <artifactId>undertow-core</artifactId>
        <version>${undertow.version}</version>
      </dependency>
    
      ...
    </dependencies>
  4. Remove the following hibernate-core exclusions from the spring-boot-starter-data-jpa groupId, artifactId, version (GAV) if it is present:

    <exclusion>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
    </exclusion>
  5. If you use the org.springframework.boot:spring-boot-maven-plugin, add the Spring Boot version to the plugin.

    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <version>${spring-boot.version}</version>
      ...
    </plugin>

After you update the dependencies, you can build and launch your Spring Boot application. For more information, see Dekorate Guide for Spring Boot Developers.

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.