← Spring Boot learning path
Spring Boot · Module 6 of 10

Configuration and profiles

Configure apps for dev, test and production.

📖 Key ideas

  1. application.yml holds settings like server.port and datasource URL.
  2. Profiles: application-dev.yml, application-prod.yml.
  3. Activate with spring.profiles.active=prod.
  4. Environment variables override properties (SPRING_DATASOURCE_URL).
  5. @ConfigurationProperties binds settings to a typed class.
💡 Real-life example: Profiles are outfits for occasions: same person (app), different clothes (settings) for office or gym.
ProfileNamed set of configuration
application.ymlMain configuration file
@ConfigurationPropertiesBinds settings to a class
Externalised configSettings outside the code