DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4
  • How Spring Boot Starters Integrate With Your Project
  • A Practical Guide to Creating a Spring Modulith Project
  • Structured Logging in Spring Boot 3.4 for Improved Logs

Trending

  • AI in Software Development: A Mirror, Not a Magic Wand
  • Reactive Kafka With Spring Boot
  • Product-Led Software Delivery: Intelligent Platforms for DevOps at Scale
  • End-to-End Event Streaming With Kafka, Spring Boot and AWS SQS/SNS (Production-Ready Code Guide)
  1. DZone
  2. Coding
  3. Frameworks
  4. Spring Boot Migration From 1.5 to 2.0.5

Spring Boot Migration From 1.5 to 2.0.5

Thinking about upgrading your Spring Boot application?

By 
Krishnan G user avatar
Krishnan G
·
Jan. 14, 19 · Tutorial
Likes (11)
Comment
Save
Tweet
Share
60.8K Views

Join the DZone community and get the full member experience.

Join For Free

Thinking of upgrading your Spring Boot application? In this post, I’d like to walk you through the process of upgrading a Spring Boot 1.x app to Spring Boot 2.

Dependencies

Java

Spring Boot 2.x will no longer support Java 7 and below, with Java 8 as the minimum requirement.

It’s also the first version to support Java 9. There are no plans to support Java 9 on the 1.x branch. If you want to use the latest Java release and take full advantage of the framework, Spring Boot 2.x is your only option.

Gradle

The Gradle minimum supported version is 3.4.

The Gradle has many value-added features to have our dependency on the central repository.

To create fat jars, bootRepackage Gradle’s task gets replaced with bootJar and bootWar to build jars and wars respectively.

It is interesting to know that Spring Boot 2.x will no longer apply the dependency management plugin by default.

If you want Spring Boot dependency management, then you should add:

apply plugin: 'io.spring.dependency-management'


A few highlights regarding minimum required versions:

  • Tomcat minimum supported version is 8.5
  • Hibernate minimum supported version is 5.2

Steps to Upgrade

Step 1:

Assuming that you are using a Gradle build tool for building your application, your build.gradle file should look as follows:

buildscript {
repositories { 
   jcenter()
   mavenCentral()
}

dependencies {
  classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
 }
}

plugins {
   id 'org.springframework.boot' version '2.0.5.RELEASE'
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'

dependencies 
{
  compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'

}


Now, this will download all the required dependency jar files for the Spring Boot verison 2.0.5 release

Step 2:

Change the application properties as follows if you used any of the following properties in your application:

Servlet-Specific Server Properties

A number of server.* properties that are servlet-specific have moved to server.servlet:

Old property New property
server.context-parameters.* server.servlet.context-parameters.*
server.context-path server.servlet.context-path
server.jsp.class-name server.servlet.jsp.class-name
server.jsp.init-parameters.* server.servlet.jsp.init-parameters.*
server.jsp.registered server.servlet.jsp.registered
server.servlet-path server.servlet.path

Here is the list of commonly used application properties

Step 3:

Replace the deprecated methods and classes. Here are some of the deprecated classes that I came across and the respective classes

Deprecated Class New Class
org.springframework.web.context.request.RequestAttributes org.springframework.web.context.request.WebRequest
org.springframework.data.querydsl.QueryDslPredicateExecutor org.springframework.data.querydsl.QuerydslPredicateExecutor
org.springframework.boot.autoconfigure.web.DefaultErrorAttributes org.springframework.boot.web.servlet.error.DefaultErrorAttributes
org.springframework.web.context.request.ServletRequestAttributes org.springframework.web.context.request.ServletWebRequest
org.springframework.boot.web.support.SpringBootServletInitializer org.springframework.boot.web.servlet.support.SpringBootServletInitializer
WebConfigurer WebMvcConfigurer


Step 4:

Now, run your main class. Your application should be up and running.

Summary

In this article, we covered steps to migrating from Spring Boot 1.5.x to Spring Boot 2.0.5, where we discussed dependencies and how Java 8 becomes the minimum supported version.

Spring Framework Spring Boot

Opinions expressed by DZone contributors are their own.

Related

  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4
  • How Spring Boot Starters Integrate With Your Project
  • A Practical Guide to Creating a Spring Modulith Project
  • Structured Logging in Spring Boot 3.4 for Improved Logs

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook