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 Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  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?

Krishnan G user avatar by
Krishnan G
·
Jan. 14, 19 · Tutorial
Like (11)
Save
Tweet
Share
58.07K 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.

Popular on DZone

  • Unleashing the Power of JavaScript Modules: A Beginner’s Guide
  • Core Machine Learning Metrics
  • Exploring the Benefits of Cloud Computing: From IaaS, PaaS, SaaS to Google Cloud, AWS, and Microsoft
  • Promises, Thenables, and Lazy-Evaluation: What, Why, How

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: