[JAVA] The story of raising Spring Boot 1.5 series to 2.1 series


Hi, this is @chan_kaku This time, Spring Boot 1.5 series will become EOL in August of this year, so I would like to try to deal with it and mention the difficult points.

About Spring Boot

Spring Boot is a framework that makes it easy to create applications based on the Spring framework. See the official documentation (https://spring.io/projects/spring-boot) for more information.

What I did (overview)

--Gradle3 series → Gradle5 series --SpringBoot 1.5 series → SpringBoot 2.1 series --Upgrade of other dependent libraries

Gradle3 series → Gradle5 series

First of all, in order to raise it to SpringBoot2 series, I had to raise the version of Gradle to 4.4 or higher, so I worked on it from here Since the target project used Gradle Wrapper was used, I modified gradle-wrapper.properties as follows.


distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip #I changed the version here

SpringBoot 1.5 series → Spring Boot 2.1 series

With the above support, Spring Boot 2 system can finally be used, so I will raise the version here. The basics can be found on the Spring Boot Github Wiki at here. please


plugins {
	id 'org.springframework.boot' version '2.1.4.RELEASE'
	id 'java'

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

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'

change point

It was not boot1.5 series, but according to Document, it seems that I had to add ʻio.spring.dependency-management`.

How to write plugins

In Gradle3 series, Java and Spring Boot were also described as follows.


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

However, from the Gradle 5 series, the writing method has changed and it is now recommended to write as a block as follows.


plugins {
    id 'org.springframework.boot' version '2.1.4.RELEASE'
    id 'java'
How to write dependencies

The way dependencies are written has also changed significantly. The writing style up to Gradle 3 series is like this.



Basically, the dependent library was written by compile. However, in Gradle 5 series, the writing style of ʻimplementation is increasing, and compileis deprecated. The difference betweencompile and ʻimplementation is simply the extent of dependency propagation. Therefore, I replaced the part written as compile with ʻimplementation` as shown below.


How to write around jar

This was also changed a little. Official documentation

I used to write like this


jar {
	baseName = "hoge"
	archiveName = "${baseName}.jar"
	version = "1.0.0-SNAPSHOT"

Of these, baseName and ʻarchiveName` were deprecated, so I modified them as follows according to Document.


jar {
    archiveBaseName = "hoge"
    archiveFileName = "${archiveBaseName}.jar"
    version = "1.0.0-SNAPSHOT"

baseName goes to ʻarchiveBaseName It seems that ʻarchiveName has been changed to ʻarchiveFileName In addition to this, ʻappendix etc. have been changed, so please have a look at the Document! !!

Other difficult points, etc.

About doma2

Doma2 was used for DB access of the project upgraded this time. In the original dependencies, I wrote as follows.



As you can see in the above way of writing dependencies, I simply replaced compile with ʻimplementation` and it got stuck in an unexpected place. I got an error saying that I can't DI because Dao's Bean is not registered in the class I'm DI I couldn't figure out the cause for a while, but once I looked at the document of doma2, there was a difference from the original build.gradle, so I made the following changes and it worked fine for Dao's Bean registration!



Until now, it worked only with doma-spring-boot-starter at the top, but I had to add'doma'itself with implement metaion. It seemed that I had to put in doma using ʻannotation Processor This annotationProcessor was added from the Gradle 5 series, and the reason why it has to be added is that the Gradle 5 series does not support the method of getting the annotation processor from the classpath at compile time. .. Therefore, if you are using not only doma but also a library that used to get the annotation processor from the classpath, you have to add ʻannotation Processor` like this.

About jackson

jackson is a Java library for processing JSON format data, which was used in this project. As in the example, when I simply replaced compile with ʻimplementaion`, I got an error about bean registration in the jackson library as in doma2. This could be solved by updating the version.


This time, in order to measure how difficult this migration is, I tried to target a project with as few dependent libraries as possible. However, there were more addictions than I had expected, and it was a difficult impression for me personally. Since the 1.5 series EOL is said to be in August of this year, we recommend that you move as soon as possible! I hope you find this article helpful.

Referenced site

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide https://qiita.com/yukina-ge/items/1ca029ed69494bfd36d6 https://qiita.com/opengl-8080/items/6ad642e0b016465891de https://doma.readthedocs.io/en/2.19.2/build/

Recommended Posts

The story of raising Spring Boot 1.5 series to 2.1 series
The story of raising Spring Boot from 1.5 series to 2.1 series part2
05. I tried to stub the source of Spring Boot
I tried to reduce the capacity of Spring Boot
Upgrade spring boot from 1.5 series to 2.0 series
About the function of Spring Boot due to different versions
Story when moving from Spring Boot 1.5 to 2.1
What I did in the migration from Spring Boot 1.4 series to 2.0 series
What I did in the migration from Spring Boot 1.5 series to 2.0 series
I want to control the default error message of Spring Boot
[Spring Boot] I investigated how to implement post-processing of the received request.
Let's check the feel of Spring Boot + Swagger 2.0
The story of adding the latest Node.js to DockerFile
[Spring Boot] How to refer to the property file
How to set environment variables in the properties file of Spring boot application
Specify the encoding of static resources in Spring Boot
A memorandum of addiction to Spring Boot2 x Doma2
Access the built-in h2db of spring boot with jdbcTemplate
The story of migrating from Paperclip to Active Storage
How to use CommandLineRunner in Spring Batch of Spring Boot
Deploy the Spring Boot project to Tomcat on XAMPP
How to boot by environment with Spring Boot of Maven
Try Spring Boot from 0 to 100.
Introduction to Spring Boot ① ~ DI ~
Introduction to Spring Boot ② ~ AOP ~
Introduction to Spring Boot Part 1
[Spring Boot] The story that the bean of the class with ConfigurationProperties annotation was not found
Deploy Spring Boot applications to Heroku without using the Heroku CLI
20190803_Java & k8s on Azure The story of going to the festival
[Java] Deploy the Spring Boot application to Azure App Service
Extract SQL to property file with jdbcTemplate of spring boot
Deploy the application created by Spring Boot to Heroku (public) ②
Deploy the application created by Spring Boot to Heroku (public) ①
The story of pushing Java to Heroku using the BitBucket pipeline
[Apache Tomcat] The story of using Apache OpenWebBeans to enable CDI
Memorandum of understanding when Spring Boot 1.5.10 → Spring Boot 2.0.0
Spring Boot for the first time
[Java version] The story of serialization
How to set Spring Boot + PostgreSQL
Going out of message (Spring boot)
The story of @ViewScoped consuming memory
The story I wanted to unzip
[Spring Boot] Role of each class
How to use ModelMapper (Spring boot)
Filter the result of BindingResult [Spring]
I want to understand the flow of Spring processing request parameters
Get a proxy instance of the component itself in Spring Boot
The story of Collectors.groupingBy that I want to keep for posterity
The story of toString () starting with passing an array to System.out.println
See the behavior of entity update with Spring Boot + Spring Data JPA
A story that made me regret when a "NotReadablePropertyException" occurred during the development of the Spring Boot application.
I want to know the Method of the Controller where the Exception was thrown in the ExceptionHandler of Spring Boot
How to apply thymeleaf changes to the browser immediately with #Spring Boot + maven
[Introduction to Spring Boot] Form validation check
How to read Body of Request multiple times with Spring Boot + Spring Security
The story of forgetting to close a file in Java and failing
The story of updating SonarQube's Docker Container
The story of switching from Amazon RDS for MySQL to Amazon Aurora Serverless
How to access Socket directly with the TCP function of Spring Integration
The story of releasing the Android app to the Play Store for the first time.
How to determine the number of parallels