0
0
Spring Bootframework~20 mins

application.properties structure in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Spring Boot Properties Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding property key-value pairs in application.properties
Which of the following lines correctly defines a property in application.properties to set the server port to 8080?
Aserver-port: 8080
Bserver.port=8080
Cserver_port=8080
Dserver.port:8080
Attempts:
2 left
💡 Hint
Look for the standard syntax using dot notation and equals sign.
component_behavior
intermediate
2:00remaining
Effect of duplicate keys in application.properties
If application.properties contains these two lines:
spring.datasource.url=jdbc:mysql://localhost:3306/db1
spring.datasource.url=jdbc:mysql://localhost:3306/db2
What will be the effective value of spring.datasource.url when the application runs?
Ajdbc:mysql://localhost:3306/db1
BBoth values are merged into a list
CAn error occurs due to duplicate keys
Djdbc:mysql://localhost:3306/db2
Attempts:
2 left
💡 Hint
Think about which value overrides the other in properties files.
📝 Syntax
advanced
2:00remaining
Correct syntax for multiline values in application.properties
Which option correctly defines a multiline property value in application.properties?
A
my.property=Line1
Line2
Line3
B
my.property=Line1
\Line2
\Line3
Cmy.property=Line1\nLine2\nLine3
D
my.property=Line1\
Line2\
Line3
Attempts:
2 left
💡 Hint
Escape sequences are used for new lines inside values.
🔧 Debug
advanced
2:00remaining
Identify the error in this application.properties snippet
Given this snippet:
server.port=8080
spring.datasource.username=root
spring.datasource.password

What error will Spring Boot raise when loading this configuration?
ANo error, empty password is allowed
BMissing value for property 'spring.datasource.password'
CDuplicate property key error
DInvalid property key syntax
Attempts:
2 left
💡 Hint
In properties files, a line with just a key sets an empty value.
state_output
expert
2:00remaining
Number of properties loaded from this application.properties
Consider this application.properties content:
app.name=TestApp
app.version=1.0
app.description=Sample app
app.name=ProdApp
app.debug=true

How many unique properties will Spring Boot load?
A4
B5
C3
D2
Attempts:
2 left
💡 Hint
Remember that duplicate keys overwrite previous ones.