0Pricing
Spring Boot 4 Microservices & REST APIs · Lesson

Refreshing Configuration at Runtime

Update config without restarting services.

Refreshing Configuration at Runtime is a free Spring Boot 4 Microservices & REST APIs lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Spring Boot 4 Microservices & REST APIs learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Config changes without restarts

By default clients read config only at startup. To apply a changed value without restarting, Spring Cloud provides runtime refresh.

The Actuator refresh endpoint

Add Spring Boot Actuator and expose the refresh endpoint. Posting to it makes the client re-fetch config from the server.

management:
  endpoints:
    web:
      exposure:
        include: refresh

Triggering a refresh

A POST to /actuator/refresh reloads the environment and returns the list of changed property keys.

// POST http://localhost:8080/actuator/refresh
// response: ["app.greeting"]   <- keys that changed

@RefreshScope

Only beans annotated with @RefreshScope are re-created on refresh, picking up new values. Without it, a bean keeps the value it got at startup.

@RefreshScope
@Component
public class GreetingService {
    @Value("${app.greeting}")
    private String greeting; // updates after /actuator/refresh
}

What gets updated

On refresh, @ConfigurationProperties beans are rebound automatically (no @RefreshScope needed), while @Value-based beans need @RefreshScope to see new values.

How @RefreshScope works

@RefreshScope wraps the bean in a proxy. On refresh the underlying instance is discarded and lazily re-created on next use, so it reads fresh config.

Refresh is per-instance

Calling /actuator/refresh updates only that one instance. In a cluster you must hit every instance - which does not scale well.

Spring Cloud Bus

Spring Cloud Bus links instances over a message broker (RabbitMQ/Kafka). A single /actuator/busrefresh then broadcasts the refresh to all instances at once.

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>

Automating with webhooks

Connect your Git provider's webhook to the Config Server's monitor endpoint so a push automatically triggers a bus refresh across the fleet - no manual call needed.

What cannot be refreshed live

Some settings only take effect at boot - e.g. server port, datasource URL for an already-built pool, or component scanning. Changing those still requires a restart.

Refresh safely

Treat refresh like a deploy: validate config in Git first, roll out gradually, and watch the returned changed-keys list to confirm only intended values changed.

Quick Check

Test your runtime-refresh knowledge.

Recap

You refreshed config at runtime:

  • Expose and POST /actuator/refresh
  • @RefreshScope re-creates @Value beans; @ConfigurationProperties rebind automatically
  • Refresh is per-instance; Spring Cloud Bus broadcasts to all
  • Some boot-time settings still need a restart

Frequently asked questions

Is the “Refreshing Configuration at Runtime” lesson free?

Yes — the full text of “Refreshing Configuration at Runtime” is free to read here on the web, and the Spring Boot 4 Microservices & REST APIs course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Spring Boot 4 Microservices & REST APIs course, upgrade to CoddyKit PRO.

What will I learn in “Refreshing Configuration at Runtime”?

Update config without restarting services. You practise Spring Boot 4 Microservices & REST APIs with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Spring Boot 4 Microservices & REST APIs?

No prior experience is required. Spring Boot 4 Microservices & REST APIs on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Refreshing Configuration at Runtime” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Spring Boot 4 Microservices & REST APIs lesson?

Yes. Every Spring Boot 4 Microservices & REST APIs lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. The Config Server
  2. Git-Backed Configuration
  3. Config Clients
  4. Refreshing Configuration at Runtime
← Back to Spring Boot 4 Microservices & REST APIs