Configurationmedium3-5 years

Why prefer @ConfigurationProperties with validation over scattering @Value across the codebase?

@ConfigurationProperties binds a whole prefix of configuration to one typed, immutable-friendly object — so related settings live together, get relaxed binding (kebab-case, env vars, YAML all resolve to the same field) for free, and can be validated with Bean Validation annotations that fail the application at startup if a value is missing or malformed, rather than throwing deep inside a request handler weeks later.

The lesson behind it →
More on Configuration