Sometimes you want to configure your Spring Boot app using a different file format than application.yml. This helps when you prefer simpler or more familiar formats.
You want to use <code>application.properties</code> instead of YAML for easier editing.
You need to override settings in environment variables for cloud deployment.
You want to use command line arguments to quickly change config without files.
You prefer JSON format for configuration in some cases.
You want to externalize config in a custom file for different environments.
B. It configures a MySQL database connection with the specified URL and credentials.
C. It disables the datasource configuration.
D. It causes a syntax error and fails to start.
Solution
Step 1: Analyze the datasource properties
The keys spring.datasource.url, username, and password configure the database connection details.
Step 2: Identify the database type and credentials
The URL contains jdbc:mysql://, indicating a MySQL database with host localhost and database mydb. Username and password are set accordingly.
Final Answer:
It configures a MySQL database connection with the specified URL and credentials. -> Option B
Quick Check:
Datasource URL with jdbc:mysql = MySQL config [OK]
Hint: Look for jdbc:mysql in URL to identify MySQL config [OK]
Common Mistakes:
Assuming PostgreSQL from MySQL URL
Thinking this disables datasource
Confusing syntax as error
4. You wrote this in application.properties:
server.port9090
Why does your Spring Boot app fail to start on port 9090?
medium
A. Spaces are not allowed anywhere in properties files.
B. Port 9090 is reserved and cannot be used.
C. Missing equals sign between key and value causes syntax error.
D. Property name is incorrect; should be server.port.number.
Solution
Step 1: Check properties file syntax
Each line must have a key and value separated by an equals sign (=) or colon (:).
Step 2: Identify the missing equals sign
The line server.port9090 lacks the equals sign, causing it to be parsed as a single key with no value and preventing the port from being set.
Final Answer:
Missing equals sign between key and value causes syntax error. -> Option C
Quick Check:
Properties need key=value format [OK]
Hint: Always use = or : between key and value [OK]
Common Mistakes:
Omitting equals sign
Using wrong property name
Assuming spaces are forbidden everywhere
5. You want to migrate your Spring Boot app configuration from application.yml to application.properties. Which of the following is the correct way to convert this YAML snippet?