12 · Spring Boot and the web request lifecycle / LESSON 53 OF 102
Profiles, property precedence, and secrets
Profiles select environment-specific configuration while the application artifact stays the same.
Before this lesson: Typed configuration properties and validation
Understand the topic
application-dev.properties can configure local behavior. Command-line arguments and environment values can override packaged defaults according to Boot property-source precedence. Diagnose the effective value instead of editing several files until startup happens to work.
Profiles are not authorization boundaries. Never make a production endpoint public merely because a profile name changed. Use deployment secrets for passwords and keys, and document required variable names without real values.
EXAMPLE · PROPERTIES
application.properties
spring.datasource.url=${JDBC_URL}
spring.datasource.username=${DB_USER}
spring.datasource.password=${DB_PASSWORD}
spring.jpa.open-in-view=falseWhat to expect
The application requires external database values. Disabling open-in-view makes persistence access boundaries explicit.
YOUR TURN
Put it into practice
- 01Run the same artifact with local and test configuration.
- 02Override one harmless property through an environment variable and document its precedence.
- 03Verify: No credential appears in Git or logs and both environments use the same built artifact.
Pass a quiz or complete a lab to check today’s streak. Each lesson counts once per day, including when you review it later.
UNDER THE HOOD
Build the mental model
Profiles select environment-specific configuration while the application artifact stays the same.
- 01application-dev.properties can configure local behavior. Command-line arguments and environment values can override packaged defaults according to Boot property-source precedence. Diagnose the effective value instead of editing several files until startup happens to work.
- 02Profiles are not authorization boundaries. Never make a production endpoint public merely because a profile name changed. Use deployment secrets for passwords and keys, and document required variable names without real values.
- 03Trace the example: The application requires external database values. Disabling open-in-view makes persistence access boundaries explicit.
A mistake worth avoiding
Editing application.properties does not change the running value.
DEBUGGING ROOM
Something broke. Where do you look?
Editing application.properties does not change the running value.
Before revealing the diagnosis, write down your first investigation step.
CHECK YOUR UNDERSTANDING
Should different environments require recompiling business code?
BUILD IT YOURSELF
Run the same artifact with local and test configuration.
- 1.Run the same artifact with local and test configuration.
- 2.Override one harmless property through an environment variable and document its precedence.
- 3.Reproduce this failure, then repair it: Editing application.properties does not change the running value.
Acceptance checklist
Lab completion is your self-report. Knowledge checks do not certify project quality.
RETRIEVE IT FROM MEMORY
Should different environments require recompiling business code?
Revisit this lesson in three days after a successful check or lab.
Ready for the next step?
No credential appears in Git or logs and both environments use the same built artifact.
Reading is separate from passing a knowledge check or completing a lab.