application.properties and YAML
Configure apps with properties and YAML files.
Where Configuration Lives
Spring Boot reads externalized configuration from application.properties or application.yml, placed under src/main/resources. This keeps tunable values out of your compiled code.
At startup Boot loads these files into the Environment, making every key available for injection, conditional beans, and auto-configuration.
- One file for the whole app, or split per profile
- Values can be overridden later by env vars or CLI args
The .properties Format
The classic format is a flat list of key=value lines. Nested concepts are expressed with dotted keys.
It is simple and diff-friendly, but verbose when you have deep structures because each key repeats the full path.
server.port=8080
server.servlet.context-path=/api
spring.datasource.url=jdbc:postgresql://localhost:5432/app
spring.datasource.username=app_user
spring.jpa.hibernate.ddl-auto=validateAll lessons in this course
- application.properties and YAML
- Profiles for Environments
- Type-Safe Configuration with @ConfigurationProperties
- Externalized and Override Configuration