Spring Boot allows both application.yml and application.properties to exist in the same project, and it merges their settings, with application.properties taking precedence on any overlapping key.
Key Points: • Both files are loaded from the same locations (classpath root, /config subdirectory, etc.). • When a key is defined in both, the value from application.properties wins. • YAML supports a hierarchical, nested structure, which is more readable for complex configuration. • Properties files are flatter, using dot-separated keys, which some teams prefer for simplicity or tooling compatibility. • Mixing both in a real project is uncommon and can be confusing; most teams pick one format for consistency.
Example: If application.yml sets server.port: 8080 and application.properties sets server.port=9090, the application will actually start on port 9090 because properties files take priority.
Code Example:
# application.yml
server:
port: 8080
# application.properties
server.port=9090Interview Tip: A concise interview answer is:
"Yes, both can coexist and Spring Boot merges them, but application.properties wins on any duplicate key. In practice I'd avoid mixing formats in one project -- pick YAML for hierarchical configuration or properties for simplicity, and stick with it to avoid confusing precedence surprises."