![]() |
VOOZH | about |
In Spring Boot applications, configuration files are used to define application-level settings such as server port, database credentials, logging levels, and environment-specific properties. Spring Boot supports two primary configuration formats:
application.yml uses YAML (Yet Another Markup Language), which supports hierarchical and structured configuration. It is more readable when dealing with complex configurations.
Example:
application.properties uses a simple key–value pair format to configure Spring Boot applications. It is easy to understand and commonly used for small or simple configurations.
Example:
Use .yml When:
Use .properties When:
| Feature | YAML(.yml) | .properties |
|---|---|---|
Specification | Well-defined YAML specification | No formal spec (based on Java documentation) |
Readability | Highly readable | Readable |
Data Types | Supports scalar, list, and map types | Values treated as strings |
Structure | Hierarchical | Flat (dot-based) |
List Support | Native | Convention-based |
Language Usage | Used across many languages | Primarily Java |
@PropertySource Support | Not supported | Supported |
Spring Profiles | Multiple profiles in one file | One file per profile |
Type Safety | Preserves actual data types | Values resolved as strings |
Verbosity | Less verbose | More verbose |