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.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.

How do Spring profiles let the same codebase behave differently in dev vs production?

Next Step

Continue to What is a Spring Boot 'starter', and why does adding one dependency configure so much automatically?← Back to all Spring Boot questions