Migrating applications to Spring Boot 2.7

Red Hat support for Spring Boot 2.7

For use with Spring Boot 2.7.18

Red Hat Customer Content Services

Abstract

The Migrating applications to Spring Boot 2.7 document contains information related to migrating older Spring Boot applications to Spring Boot 2.7.18.

Providing feedback on Red Hat documentation

We appreciate your feedback on our documentation. To provide feedback, you can highlight the text in a document and add comments.

This section explains how to submit feedback.

Prerequisites

  • You are logged in to the Red Hat Customer Portal.
  • In the Red Hat Customer Portal, view the document in Multi-page HTML format.

Procedure

To provide your feedback, perform the following steps:

  1. Click the Feedback button in the top-right corner of the document to see existing feedback.

    Note

    The feedback feature is enabled only in the Multi-page HTML format.

  2. Highlight the section of the document where you want to provide feedback.
  3. Click the Add Feedback pop-up that appears near the highlighted text.

    A text box appears in the feedback section on the right side of the page.

  4. Enter your feedback in the text box and click Submit.

    A documentation issue is created.

  5. To view the issue, click the issue tracker link in the feedback view.

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

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.

Legal Notice

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.