0PricingLogin
Spring Boot 4 Microservices & REST APIs · Lesson

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=validate

All lessons in this course

  1. application.properties and YAML
  2. Profiles for Environments
  3. Type-Safe Configuration with @ConfigurationProperties
  4. Externalized and Override Configuration
← Back to Spring Boot 4 Microservices & REST APIs