Java EE
Spring Boot
hot-reloading
properties file
application development

How to hot-reload properties in Java EE and Spring Boot?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Hot-reloading properties can mean two different things: restarting the application automatically when files change, or re-reading configuration at runtime without a full restart. Those are not the same feature, and confusing them leads to fragile setups. In Spring Boot and Java EE, the right solution depends on whether you are optimizing developer feedback or truly changing live configuration.

Spring Boot: restart-based reload in development

Spring Boot DevTools is useful for development because it watches the classpath and restarts the application when supported files change.

xml
1<dependency>
2    <groupId>org.springframework.boot</groupId>
3    <artifactId>spring-boot-devtools</artifactId>
4    <scope>runtime</scope>
5</dependency>

If you edit application.properties or classpath resources in development, DevTools can trigger a restart so the new values are picked up. That feels like hot reload, but technically it is an automatic restart, not live rebinding of existing beans.

That distinction matters because infrastructure-related properties, datasource settings, and bean wiring still rely on application startup logic.

Spring Boot: true runtime refresh needs extra design

If you want values to change without a full restart, you typically need:

  • Externalized configuration
  • Beans designed for refresh or lookup
  • A trigger mechanism for reloading

A common Spring approach is binding configuration through @ConfigurationProperties and using a refresh-capable architecture.

java
1import org.springframework.boot.context.properties.ConfigurationProperties;
2
3@ConfigurationProperties(prefix = "app")
4public class AppProperties {
5    private String message;
6
7    public String getMessage() {
8        return message;
9    }
10
11    public void setMessage(String message) {
12        this.message = message;
13    }
14}

In plain Spring Boot alone, changing the property file on disk does not magically update already-created singleton beans in production. For live refresh behavior, teams often introduce Spring Cloud configuration patterns or custom file-watching and rebinding logic.

Java EE: no universal built-in property hot reload

Java EE does not provide one universal switch that makes every .properties file hot-reload automatically across containers. The common pattern is externalizing configuration and designing your code so values are either:

  • Looked up on demand
  • Cached with controlled refresh
  • Reloaded through a managed configuration source

A simple file-based approach might look like this:

java
1import java.io.IOException;
2import java.io.InputStream;
3import java.nio.file.Files;
4import java.nio.file.Path;
5import java.util.Properties;
6
7public class PropertyLoader {
8    private final Path path;
9
10    public PropertyLoader(Path path) {
11        this.path = path;
12    }
13
14    public Properties load() throws IOException {
15        Properties properties = new Properties();
16        try (InputStream in = Files.newInputStream(path)) {
17            properties.load(in);
18        }
19        return properties;
20    }
21}

This is not automatic hot reload by itself, but it shows the core idea: treat configuration as an external source and decide when to re-read it.

Design for refreshable configuration

The deeper lesson is that not every property should be hot-reloadable. Some values are safe to refresh at runtime, such as feature flags, messages, or thresholds. Others, such as connection pools or server port settings, are tied to infrastructure that was created during startup.

A strong design separates these categories. Runtime-tunable settings can live behind a refreshable configuration service, while startup-only settings remain restart-bound.

Common Pitfalls

The biggest mistake is calling every restart-on-change feature "hot reload." If the application restarts, that is still a restart, even if it is convenient.

Another issue is expecting a changed application.properties file to update existing Spring singleton beans automatically in production. Plain Spring Boot does not work that way.

In Java EE, developers often hard-code property loading during application startup and then expect those values to evolve without any reload path. If the values are only read once, they will stay fixed.

Finally, do not try to make every property dynamic. Some configuration belongs to startup and should remain that way for predictability and safety.

Summary

  • Restart-based reload and true runtime refresh are different problems.
  • Spring Boot DevTools helps in development by restarting on changes.
  • Plain Spring Boot does not automatically rebind live beans when properties change.
  • Java EE usually needs explicit external configuration and reload logic.
  • Only make properties dynamically refreshable when the application can safely support it.

Related reading
Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.