eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – LJB – NPI EA (cat = Core Java)
announcement - icon

Code your way through and build up a solid, practical foundation of Java:

>> Learn Java Basics

Partner – LambdaTest – NPI EA (cat= Testing)
announcement - icon

Distributed systems often come with complex challenges such as service-to-service communication, state management, asynchronous messaging, security, and more.

Dapr (Distributed Application Runtime) provides a set of APIs and building blocks to address these challenges, abstracting away infrastructure so we can focus on business logic.

In this tutorial, we'll focus on Dapr's pub/sub API for message brokering. Using its Spring Boot integration, we'll simplify the creation of a loosely coupled, portable, and easily testable pub/sub messaging system:

>> Flexible Pub/Sub Messaging With Spring Boot and Dapr

1. Introduction

In this tutorial, we’ll explore a support system provided by Spring to facilitate Spring Boot upgrades. In particular, we’ll be looking at the spring-boot-properties-migrator module. It helps migrate application properties.

With each Spring Boot version upgrade, there may be properties that are either marked as deprecated, have gone out of support, or were newly introduced. Spring publishes the comprehensive changelog for each upgrade. However, these changelogs can be a bit tedious to go through. That’s where the spring-boot-properties-migrator module comes to the rescue. It does so by providing us with personalized information for our setup.

Let’s see this in action!

2. Demo Application

Let’s upgrade our Spring Boot application from version 2.3.0 to 2.6.3.

2.1. Properties

In our demo application, we have two properties files. In the default properties file, application.properties, let’s add:

spring.resources.cache.period=31536000
spring.resources.chain.compressed=false
spring.resources.chain.html-application-cache=false

For the dev profile YAML file application-dev.yaml:

spring:
  resources:
    cache:
      period: 31536000
    chain:
      compressed: true
      html-application-cache: true

Our properties files contain several properties that have either been replaced or removed between Spring Boot 2.3.0 and 2.6.3. Additionally, we also have both .properties and .yaml files for a better demonstration.

2.2. Adding the Dependency

Firstly, let’s add the spring-boot-properties-migrator as a dependency in our module:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-properties-migrator</artifactId>
    <scope>runtime</scope>
</dependency>

If we’re using Gradle, we can add:

runtime("org.springframework.boot:spring-boot-properties-migrator")

The scope of the dependency should be runtime.

3. Running the Scan

Secondly, let’s package and run our application. We’ll be using Maven to build and package:

mvn clean package

Finally, let’s run it:

java -jar target/spring-boot-properties-migrator-demo-1.0-SNAPSHOT.jar

As a result, the spring-boot-properties-migrator module scans our application properties files and works its magic! More on that in a bit.

4. Understanding the Scan Output

Let’s go through the logs to understand the scan’s recommendations.

4.1. Replaceable Properties

For the properties that have a known replacement, we see WARN logs from the PropertiesMigrationListener class:

WARN 34777 --- [           main] o.s.b.c.p.m.PropertiesMigrationListener  : 
The use of configuration keys that have been renamed was found in the environment:

Property source 'Config resource 'class path resource [application.properties]' via location 'optional:classpath:/'':
	Key: spring.resources.cache.period
		Line: 2
		Replacement: spring.web.resources.cache.period
	Key: spring.resources.chain.compressed
		Line: 3
		Replacement: spring.web.resources.chain.compressed

Property source 'Config resource 'class path resource [application-dev.yaml]' via location 'optional:classpath:/'':
	Key: spring.resources.cache.period
		Line: 5
		Replacement: spring.web.resources.cache.period
	Key: spring.resources.chain.compressed
		Line: 7
		Replacement: spring.web.resources.chain.compressed


Each configuration key has been temporarily mapped to its replacement for your convenience. To silence this warning, please update your configuration to use the new keys.

We see all the key information in the logs, such as which property file, key, line number, and replacement key pertains to each entry. This helps us easily identify and replace all such properties. Additionally, the module replaces these properties with available replacements at runtime, allowing us to be able to run the application without having to make any changes.

4.2. Unsupported Properties

For the properties that don’t have a known replacement, we see ERROR logs from the PropertiesMigrationListener class:

ERROR 34777 --- [           main] o.s.b.c.p.m.PropertiesMigrationListener  : 
The use of configuration keys that are no longer supported was found in the environment:

Property source 'Config resource 'class path resource [application.properties]' via location 'optional:classpath:/'':
	Key: spring.resources.chain.html-application-cache
		Line: 4
		Reason: none

Property source 'Config resource 'class path resource [application-dev.yaml]' via location 'optional:classpath:/'':
	Key: spring.resources.chain.html-application-cache
		Line: 8
		Reason: none

Like the previous scenario, we see the offending property file, the key, the line number in the property file, and the reason behind the key being removed. But, unlike in the previous scenario, the startup of the application may fail depending on the property in question. We might also face runtime issues since these properties couldn’t be migrated automatically.

5. Updating the Configuration Properties

Now, with the crucial information provided to us by the scan, we’re in a much better state to upgrade the properties. We know the property file to go to, the line number, and the key to either replace with the suggested replacement or consult the release notes for the specific keys that have no replacement.

Let’s fix our properties files. In the default properties file, application.properties, let’s replace the properties as per the recommendation:

spring.web.resources.cache.period=31536000
spring.web.resources.chain.compressed=false

Similarly, let’s update the dev profile YAML file application-dev.yaml:

spring:
  web:
    resources:
      cache:
        period: 31536000
      chain:
        compressed: false

To summarize, we’ve replaced the properties spring.resources.cache.period with spring.web.resources.cache.period and spring.resources.chain.compressed with spring.web.resources.chain.compressed. The spring.resources.chain.html-application-cache key is no longer supported in the new version. Hence, we’ve removed it in this case.

Let’s once again run the scan. First, let’s build the application:

mvn clean package

Then, let’s run it:

java -jar target/spring-boot-properties-migrator-demo-1.0-SNAPSHOT.jar

Now, all the information logs we saw earlier from the PropertiesMigrationListener class disappear, indicating that our properties migration is successful!

6. How Does All This Work? A Peek Under the Hood

A Spring Boot Module JAR contains a spring-configuration-metadata.json file in the META-INF folder. These JSON files are the sources of the information for the spring-boot-properties-migrator module. When it scans our properties files, it pulls the relevant properties’ metadata information from these JSON files to build the scan report.

An example from the file shows the various information that we see in the generated reports:

In spring-autoconfigure:2.6.3.jarMETA-INF/spring-configuration-metadata.json, we’ll find the entry for spring.resources.cache.period:

{
    "name": "spring.resources.cache.period",
    "type": "java.time.Duration",
    "deprecated": true,
    "deprecation": {
        "level": "error",
        "replacement": "spring.web.resources.cache.period"
    }
}

Similarly, in spring-boot:2.0.0.RELEASE.jar META-INF/spring-configuration-metadata.json, we’ll find the entry for banner.image.location:

{
    "defaultValue": "banner.gif",
    "deprecated": true,
    "name": "banner.image.location",
    "description": "Banner image file location (jpg\/png can also be used).",
    "type": "org.springframework.core.io.Resource",
    "deprecation": {
        "level": "error",
        "replacement": "spring.banner.image.location"
    }
}

7. Caveats

Before we wrap this article, let’s go over some of the caveats with the spring-boot-properties-migrator.

7.1. Don’t Keep This Dependency in Production

This module is meant to be used only during the upgrades in development environments. Once we identify the properties to be updated or removed and then correct them, we can remove the module from our dependencies. Eventually, we should never include this module in higher environments. It’s not recommended due to certain costs associated with it.

7.2. Historical Properties

We shouldn’t jump the versions during upgrades because the module may not be able to detect the really old properties deprecated in the much older versions. For example, let’s add banner.image.location to our application.properties file:

banner.image.location="myBanner.txt"

This property was deprecated in Spring Boot 2.0. If we try to run our application with Spring Boot version 2.6.3 directly, we won’t see any warning or error message regarding it. We’d have to run the scan with Spring Boot 2.0 to be able to detect this property:

WARN 25015 --- [           main] o.s.b.c.p.m.PropertiesMigrationListener  : 
The use of configuration keys that have been renamed was found in the environment:

Property source 'applicationConfig: [classpath:/application.properties]':
    Key: banner.image.location
	Line: 5
	Replacement: spring.banner.image.location


Each configuration key has been temporarily mapped to its replacement for your convenience. To silence this warning, please update your configuration to use the new keys.

8. Conclusion

In this article, we explored the spring-boot-properties-migrator. It’s a handy tool that scans our properties file and gives easily actionable scan reports. We also looked at the high-level view of how the module achieves its feat. Finally, to ensure this tool’s best utilization, we went over a few caveats.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

eBook Jackson – NPI EA – 3 (cat = Jackson)