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.
PreviousHow does Spring Boot decide which value wins when the same property is set in application.yml, a profile-specific file, an environment variable and a command-line argument?Next How does Spring Boot Actuator's /health endpoint combine multiple health indicators into one status, and how do liveness and readiness differ?