Use of springboot~application.properties and APPLICATION.YML

Source: Internet
Author: User

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

    1. The original key, such as spring. data. MongoDB. Uri, press "." Split, all into a tree-like configuration
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.