Bird
0
0

You have this in application.properties:

medium📝 Debug Q7 of 15
Spring Boot - Application Configuration
You have this in application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/db
spring.datasource.username=root
spring.datasource.password=pass
spring.datasource.url=jdbc:mysql://localhost:3306/otherdb

Which database URL will Spring Boot use?
Ajdbc:mysql://localhost:3306/otherdb
Bjdbc:mysql://localhost:3306/db
CAn error occurs due to duplicate keys
DThe first URL is used, ignoring the second
Step-by-Step Solution
Solution:
  1. Step 1: Understand duplicate keys in properties

    When duplicate keys exist, Spring Boot uses the last occurrence's value.
  2. Step 2: Identify the last URL value

    The last spring.datasource.url is set to jdbc:mysql://localhost:3306/otherdb.
  3. Final Answer:

    jdbc:mysql://localhost:3306/otherdb -> Option A
  4. Quick Check:

    Duplicate keys = last wins in properties files [OK]
Quick Trick: Last duplicate key value wins in properties [OK]
Common Mistakes:
  • Assuming first key wins
  • Expecting an error on duplicates
  • Thinking values merge

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes