At the beginning of the project in the Springboot framework, we can store the configuration file in the Resource folder, and the format can have two kinds, the properties and Yml, the former is a flat k/v format, and the latter is the YML tree structure, we recommend using the latter, Because it is more readable, if the existing is the properties, can also be converted to YML format, we put properies. to split.
For example: The following is the configuration of the properties format
SPRING.DATA.MONGODB.URI=MONGODB://192.168.200.214:27017/test
After splitting it into a yml format, it becomes like this
Spring: data: MongoDB: uri:mongodb://192.168.200.214:27017/test
It is naturally a tree-type construction, more readable! We are doing yml writing if we need to pay attention to the following questions
- The original key, such as spring. data. MongoDB. Uri, press "." Split, all into a tree-like configuration
- The colon after the key of the last element must be followed by a space
Thank you for reading!
Use of springboot~application.properties and APPLICATION.YML