Chapter 2. Upgrade to Spring Boot 2


This chapter explains how to upgrade your applications to Spring Boot 2.0 from Spring Boot 1.

2.1. Before you begin

Before you start the migration to Spring Boot 2, you must review the system requirements and dependencies.

  • Upgrade to the latest 1.5.x version

    • Before you start, upgrade to the latest 1.5.x available version. This is to ensure that you are building against the most recent dependencies of that line.
  • Review dependencies

    • The migration to Spring Boot 2 will result in upgrading a number of dependencies. Review the dependency management for 1.5.x with the dependency management for 2.0.x to assess how your project is affected.
    • Identify the compatible versions for the dependencies that are not managed by Spring Boot and then define the explicit versions for these.
  • Review custom configuration

    • Any custom configuration that your project defines might need to be reviewed on upgrade. If this can be replaced by the use of standard auto-configuration, do it so before upgrading.
  • Review system requirements

    • Spring Boot 2.0 requires Java 8 or later.
    • It also requires Spring Framework 5.0.
    • Java 6 and 7 are no longer supported.

2.2. Upgrade from Spring Boot 1 to Spring Boot 2

Once you have reviewed the state of your project and its dependencies, upgrade to the latest maintenance release of Spring Boot 2.x. It is recommended to upgrade in the phases. For example, first upgrade from Spring Boot 1.5 to Spring Boot 2.0 and then upgrade to 2.1 and then to the latest maintenance release of Spring Boot 2.

Migrating configuration properties

With Spring Boot 2.0, many configuration properties were renamed or removed. Hence you need to update the application.properties/application.yml accordingly. You can achieve that with the help of a new spring-boot-properties-migrator module. Once added as a dependency to your project, this will not only analyze your application’s environment and print diagnostics at startup, but also temporarily migrate properties at runtime for you.

Procedure

  1. Add spring-boot-properties-migrator module to dependency section of your project’s pom.xml.
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-properties-migrator</artifactId>
	<scope>runtime</scope>
</dependency>

runtime("org.springframework.boot:spring-boot-properties-migrator")
Note

Once you’re done with the migration, please make sure to remove this module from your project’s dependencies.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.