Upgrade A Spring Boot Project from 2.0 to 2.1
Upgrade Java, Spring Boot, Gradle, Flyway, etc.
Why upgrade
- Faster
- Security
- Eliminate risks of upgrading to a higher version
Processes
- Before the upgrade, run all unit tests
- Upgrade Gradle, Spring Boot, Java
- Implement fix to make it builds
- Run Unit tests or implements fix
Details
Update Gradle wrapper from 4.7 to 5.6
-
Update local Gradle to the latest version (5.6)
sdk list gradle sdk use gradle 5.6.2
-
Generate lastest Gradle Wrapper
gradle wrapper
-
Check
gradle/wrapper/gradle-wrapper.properties
filedistributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
Upgrade Spring Boot from 2.0 to 2.1.8
-
Generate new
build.gradle
Go to Spring Initializr, regenerate your dependencies. It uses a new default format of
build.gradle
and latest version. Tick Java 11, we’ll talk it later. -
Allow bean definition override
spring.main.allow-bean-definition-overriding=true
- We customized
Flyway
bean to run with dynamic databases. - We override bean in unit tests because we don’t want the real instance to load.
- We customized
-
Lombok changes
Spring Boot 2.1 has upgraded to Lombok
1.18.x
from1.16.x
. In1.18
, Lombok will no longer generate a private, no-args constructor by default. It can be enabled by settinglombok.noArgsConstructor.extraPrivate=true
in alombok.config
configuration file. -
Flyway changes
//todo
-
Junit from v4 to v5
//todo
Oracle Java 8 to OpenJDK Java 11
There is a Java 9 introduced bug, please see this interesting blog.
// todo a workaround