How to Track Spring Boot Configuration Values with /actuator/configprops
This guide explains how to use Spring Boot's Actuator /actuator/configprops endpoint to track and retrieve real-time configuration property values across multiple environments, handle profile-specific settings, customize sensitive data masking, and integrate checks into CI pipelines.
Background
When using Spring Boot for multi-environment packaging, configuration property values differ across environments, e.g.:
<code>spring:
profiles:
active: @project.profile@ # dynamically set profile via Maven
---
spring:
profiles: dev
key: lengleng_dev
---
spring:
profiles: prd
key: lengleng_prd
</code>Or using Spring Cloud Config Center (Nacos, etc.).
The same property may come from configuration files, environment variables, or startup parameters, leading to unexpected values at runtime.
Solution
Spring Boot 2.3 Actuator provides the
/actuator/configpropsendpoint (previous versions also had
/actuator/env) to track configuration file properties in real time.
How to Use
Include the Actuator dependency:
<code><dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</code>Expose the
configpropsendpoint:
<code>management:
endpoints:
web:
exposure:
include: 'configprops'
</code>Create a configuration class:
<code>@Data
@Component
@ConfigurationProperties("demo")
public class DemoConfig {
private String username;
private String password;
}
</code>Access the endpoint to get real-time property values.
Special Notes
The configprops endpoint masks sensitive fields by default, using keywords such as password, secret, key, token, .*credentials.*, vcap_services, sun.java.command.
<code>public class Sanitizer {
private static final String[] REGEX_PARTS = { "*", "$", "^", "+" };
private static final Set<String> DEFAULT_KEYS_TO_SANITIZE = new LinkedHashSet<>(Arrays.asList(
"password", "secret", "key", "token", ".*credentials.*", "vcap_services", "sun.java.command"));
}
</code>Customize sanitization rules:
<code>management:
endpoint:
configprops:
keys-to-sanitize:
- 'aaa'
- 'bbb'
</code>If a configuration property is null, it will not be displayed by the endpoint.
Summary
The configprops endpoint maps to
ConfigurationPropertiesReportEndpointand demonstrates how to retrieve configuration values from
PropertySource.
Use case: CI pipelines should query this endpoint before running tests to ensure configurations match expectations.
Source code example: https://github.com/lltx/spring-boot-course
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.