In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "the method introduction of springboot configuration file". In the daily operation, I believe that many people have doubts about the method introduction of springboot configuration file. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "method introduction of springboot configuration file". Next, please follow the editor to study!
1. What is YML
SpringBoot uses a global configuration file with a fixed profile name
Application.propertiesapplication.yml
The role of the configuration file: modify the default values for SpringBoot automatic configuration
YAML (YAML Ain't Markup Language)
YAML A Markup Language: is a markup language
YAML isn't Markup Language: not a markup language
Markup language:
Previous configuration files; most use xxx.xml files
YAML: data-centric, more suitable for configuration files than json, xml, etc.
YAML: configuration example server:
Port: 5658
XML: configuration example
5658
2. YML syntax
K: (space) v: represents a pair of key-value pairs (spaces must have)
Control the hierarchical relationship with the indentation of spaces; as long as a column of data that is left-aligned is at the same level
Server:
Port: 5658
Path: / hello
Properties and values are also case-sensitive
Literal quantity
Normal values (numbers, strings, Boolean)
K: v literally write directly
Strings do not need single or double quotation marks by default; "": double quotes; special characters are not escaped; special characters are used as their intended meaning name: "zhangsan\ n lisi": output; zhangsan line feed lisi'': single quotation marks; escape special characters, which are ultimately just a normal string data name: 'zhangsan\ n lisi': output; zhangsan\ n lisi
Summary:
For the value of the string, the effect of writing directly is the same as adding single quotation marks. If you want to use the function of special characters, you need to add double quotes, for example:\ nIf it is in double quotes, it will be used as a newline.
Object, Map
(attributes and values) (key-value pairs):
K: v: write the relationship between the properties and values of the object on the next line; note the indentation
The object is still the way of k: v
Friends:
LastName: zhangsan
Age: 20
Inline writing:
Friends: {lastName: zhangsan, age: 18}
Array
(List, Set):
Use a-value to represent an element in an array
Pets:
-cat
-dog
-pig
Inline writing
Pets: [cat, dog, pig]
At this point, the study of "introduction to the method of springboot configuration file" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.