---
title: "Configuration, properties, and profiles"
chapter: "05"
---

# Configuration, properties, and profiles

Code should describe behavior. Configuration should describe what changes
between environments.

## Typed properties

Use `@ConfigurationProperties` for a group of related settings. Typed objects
provide validation, metadata, and one place to understand configuration.
Prefer them over many scattered `@Value` expressions.

```java
@ConfigurationProperties("payments")
public record PaymentProperties(
    @NotBlank URI endpoint,
    @Positive Duration timeout) {}
```

## Property precedence

Spring Boot combines files, environment variables, system properties, command
line arguments, test properties, and other sources with a defined precedence.
Know which source wins. Do not let an emergency command-line override become an
invisible permanent configuration.

## Profiles

Profiles activate groups of beans or properties. Use them sparingly for genuine
environment capabilities. Avoid profile combinations such as
`prod-eu-blue-customer7`; they create untestable configuration branches.

## Secrets

Do not store passwords or tokens in source control. Retrieve them from a secret
manager or injected runtime source. Ensure logs and Actuator endpoints do not
expose them. Plan rotation and application reload.

## Validation and failure

Validate required configuration at startup with clear messages. A service that
starts with a blank payment endpoint is not “resilient”; it is misleading.

## Feynman check

Configuration is a labeled control panel. Typed properties group related
switches, validation stops impossible settings, and a secret manager keeps the
master key away from the panel.
