Spring Boot FAQ: Top Questions
37. How do you externalize configuration using YAML files?
Spring Boot supports YAML (.yml) format for configuration in place of application.properties. It is used for hierarchical data structures and improved readability.
📥 Example:
server:
port: 8082
spring:
datasource:
url: jdbc:mysql://localhost:3306/mydb
username: user
password: pass
🏆 Expected Output:
App starts on port 8082 with MySQL configured from YAML.
🛠️ Use Cases:
- Managing complex or nested config.
- Organizing profile-specific settings.
