Java / Micronaut Interview questions
How does Micronaut resolve configuration properties across multiple environments?
Micronaut resolves configuration through its Environment abstraction, which merges multiple property sources by a defined precedence order rather than picking just one file.
- Command-line arguments (highest precedence).
- Properties set via
System.getProperties(). - Environment variables.
- Environment-specific config files, such as
application-prod.yml. - The base
application.yml(lowest precedence among file sources).
Active environments are determined automatically from the MICRONAUT_ENVIRONMENTS variable, cloud platform detection, or explicit environment calls in code, and can also stack; for example running with both cloud and prod active layers both sets of overrides on top of the base file, with later-loaded, more specific sources winning on key conflicts.
Distributed configuration sources like Consul KV or AWS Parameter Store slot into this same resolution chain as additional property sources, and can be marked @Refreshable so beans depending on them are recreated automatically when a refresh event fires, without restarting the application.
More Related questions...