
Book's Upgrade: Migrating from Spring Boot 2.5 to 2.6
This chapter describes how to upgrade the book’s source code to Spring Boot 2.6.2 and Spring Cloud 2021.0. Good news: a very simple update this time, I didn’t need any changes apart from the version updates.
- Good news: a very smooth upgrade
- Migrate to Spring Boot 2.6.2 and Spring Cloud 2021.0
- A minor remark: an annoying stack trace on MacOS
- Summary
Good news: a very smooth upgrade
The last upgrades (check the list of additional chapters) introduced some breaking changes in the book repositories. This time you only need to update the versions to make the code work with the latest releases.
This has been quite surprising for me since a new major version of Spring Cloud, 2021.0, has been released, and it’s needed to run Spring Boot 2.6. Luckily, the breaking changes don’t apply to the features and modules used in this microservice architecture.
We’ll take as a baseline the last changes to upgrade the projects to Spring Boot 2.5. The new source code is available on GitHub (while you’re there, give it a star!).
Migrate to Spring Boot 2.6.2 and Spring Cloud 2021.0
First, we update the pom.xml
files in all the Spring Boot projects. See Listing 1 as an example (multiplication service).
- The version of the
spring-boot-starter-parent
dependency has been set to 2.6.2. All the library dependencies will be also upgraded following this parent pom. - The project version has changed to
2.6.2-SNAPSHOT
to make it consistent with our previous versions of the projects. - We upgraded Spring Cloud to the latest version,
2021.0.0
.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>microservices.book</groupId>
<artifactId>multiplication</artifactId>
<version>2.6.2-SNAPSHOT</version>
<name>multiplication</name>
<description>Multiplication Microservice - Learn Microservices with Spring Boot - Upgrade 2.6.2</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2021.0.0</spring-cloud.version>
</properties>
<dependencies>
<!-- ... they remain the same, versions are updated because of the parent -->
</dependencies>
</project>
Listing 1. Upgrading Spring Boot and Spring Cloud
A minor remark: an annoying stack trace on MacOS
After this update, I see a long stacktrace in the Gateway service with a message as summarized in this excerpt:
i.n.r.d.DnsServerAddressStreamProviders : Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.
...
Caused by: java.lang.UnsatisfiedLinkError: 'io.netty.resolver.dns.macos.DnsResolver[] io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider.resolvers()'
You only see this message if you’re running the project in MacOS. It seems that this issue has been always there but its logging level was promoted in one of the latest versions. Now we see it in the console. It doesn’t have any impact on the running microservice though.
For more details about this topic, see:
- https://github.com/netty/netty/issues/11020
- https://github.com/netty/netty/pull/10848
Summary
That’s all, a very simple update this time. You can rebuild the Docker images and boot up the entire system in containers if you want. Use the updated docker-compose.yml
file pointing to the new image names.
If you still don’t have the book, I strongly recommend you get your copy now. I keep updating the book’s source code and will be sharing more content around the same use case.

Comments