0
0
Spring Bootframework~20 mins

Configuration precedence order in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Spring Boot Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Spring Boot Configuration Precedence
In Spring Boot, multiple configuration sources can define the same property. Which source has the highest priority when resolving the value of a property?
ACommand line arguments
BEnvironment variables
Capplication.properties file in src/main/resources
DDefault properties set programmatically
Attempts:
2 left
💡 Hint
Think about how you might override a property quickly when running your app.
component_behavior
intermediate
2:00remaining
Property Value Resolution in Spring Boot
Given the following property sources, which value will Spring Boot use for the property server.port when the application starts?

- application.properties file: server.port=8080
- Environment variable: SERVER_PORT=9090
- Command line argument: --server.port=7070
A8080
B7070
C9090
DDefault port 80
Attempts:
2 left
💡 Hint
Remember which source overrides others in Spring Boot.
📝 Syntax
advanced
2:00remaining
Identifying Configuration Source Priority Error
Which of the following Spring Boot property source declarations will cause the application.properties file to be ignored, making environment variables take precedence?
ASetting <code>spring.config.location</code> to a non-existent directory
BUsing <code>@PropertySource</code> annotation on a configuration class
CPlacing <code>application.properties</code> in <code>src/main/resources</code>
DSetting <code>spring.config.name</code> to <code>application</code>
Attempts:
2 left
💡 Hint
Consider what happens if Spring Boot cannot find the config file location.
state_output
advanced
2:00remaining
Resulting Property Value with Multiple Sources
Consider a Spring Boot app with these property sources:
- application.properties: app.mode=dev
- application-dev.properties: app.mode=development
- Environment variable: APP_MODE=production
- Command line argument: --app.mode=staging

If the app is started with the profile dev, what is the final value of app.mode?
Aproduction
Bdevelopment
Cstaging
Ddev
Attempts:
2 left
💡 Hint
Profile-specific properties are overridden by command line arguments.
🔧 Debug
expert
3:00remaining
Debugging Unexpected Property Value in Spring Boot
A developer sets spring.config.additional-location to a directory containing application.properties with feature.enabled=false. The default application.properties in src/main/resources has feature.enabled=true. The app always uses false for feature.enabled. Why?

Choose the correct explanation.
AEnvironment variables always override <code>spring.config.additional-location</code>.
B<code>spring.config.additional-location</code> properties are ignored if default <code>application.properties</code> exists.
CThe property <code>feature.enabled</code> is case-sensitive and mismatched.
D<code>spring.config.additional-location</code> properties override default locations, so <code>false</code> is used.
Attempts:
2 left
💡 Hint
Check how additional locations affect property precedence.