beginnerProperties, Profiles & Starters
How do Spring profiles let the same codebase behave differently in dev vs production?
You define `application-dev.properties` and `application-prod.properties` alongside the base `application.properties`; whichever profile is active (`spring.profiles.active=dev`) has its file's properties layered on top of the base ones, overriding any matching keys. Beans can also be profile-scoped with `@Profile("dev")` so, for example, a fake in-memory email sender only exists in dev while a real SMTP client backs production.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response