In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to understand the SpringBoot configuration file, the content of the article is of high quality, so Xiaobian shares it with you as a reference, I hope you have a certain understanding of relevant knowledge after reading this article.
1. File Type 1.1 properties
Same as previous properties.
1.2yaml Profile
YAML is a recursive acronym for YAML Ain't Markup Language (YAML is not a markup language). YAML actually meant "Yet Another Markup Language"(still a markup language) when it was developed.
Ideal for data-centric profiles.
basic syntax
key: value;kv with spaces
case sensitive
Use indentions to represent hierarchical relationships
Tabs are not allowed, only spaces are allowed.
The number of spaces indented doesn't matter, as long as elements at the same level are left justified.
#indicates comment
Strings do not need to be quoted. If you do,' ' escapes, and " " does not escape.
For example: "zhangsan\n small Pipi", single quotation marks will not wrap, double quotation marks will wrap.
data type
A single, indivisible value. date、boolean、string、number、null
k: v
Object: A collection of key-value pairs. map、hash、set、object
Inline writing: k: {k1: v1,k2: v2,k3: v3}
#or
k:
k1: v1
k2: v2
k3: v3
Array: A set of ordered values. array、list、queue
Inline writing: k: [v1,v2,v3]
#Or
k:
- v1
- v2
- v3
example
Two Entity Classes
@Data//lombok, Here has helped us to encapsulate the get, set method public class Person { private String userName; private Boolean boss; private Date birth; private Integer age; private Pet pet; private String[] interests; private List animal; private Map score; private Set salarys; private Map allPets;}@Datapublic class Pet { private String name; private Double weight;}
Yaml configuration:
# yaml represents the above object person: userName: zhangsan boss: false birth: 2019/12/12 20:12:33 age: 18 pet: name: tomcat weight: 23.4 interests: [basketball, swimming] animal: - jerry - mario score: english: first: 30 second: 40 third: 50 math: [131,140,148] chinese: {first: 128,second: 136} salarys: [3999,4999.98,5999.99] allPets: sick: - {name: tom} - {name: jerry,weight: 47} health: [{name: mario,weight: 47}]2. Configuration tips
Custom class and profile bindings are generally not prompted.
It can be seen that if you use spring's internal configuration in the yaml file, there will be a prompt, but if you use the class we defined, there will be no prompt. To improve development efficiency, just add dependencies to pom.xml:
org.springframework.boot spring-boot-configuration-processor true org.springframework.boot spring-boot-maven-plugin org.springframework.boot spring-boot-configuration-processor
Effect after adding dependency:
About how to understand the SpringBoot configuration file to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.