Java springboot yaml syntax notes
- 2021-11-13 01:41:32
- OfStack
yaml syntax notes
Configuration file
Two forms
application. properties and.yaml
The first syntax key = value
Type 2 key: Space value
Used to modify the default configuration of spring
YAML:
YAML is a recursive abbreviation for "YAML Ain 't a Markup Language" (YAML is not a markup language). When developing this language, YAML actually means "Yet Another Markup Language" (still a markup language), but to emphasize that this language is data-centered, not markup language-centered, it is renamed with reverse abbreviations.
YAML A Markup Language is a markup language
YAML isnot Markup Language: Not a markup language
YAML
server:
port:8080
xml
<servlet>
<port>8080</port>
</servlet>
yaml Syntax
High requirements for spaces
# Ordinary ky-value
name:qinjiang
# Object
student:
name: qinjiang
age: 3
# Inline writing
students: {name: qinjiang,age: 3}
# Array
pets:
- cat
- dog
- pig
pets: [cat,dog,pig]
Official recommendation of properties
# Only key-value pairs can be maintained
name=qinjiang
student.name = qinjiang
student.age=3
When configuring multiple ports without yaml, you need to create a new properties file
Not required with yaml
server:
port:8081
spring:
profiles:
active: dev
---
server:
port:8082
spring:
profiles:dev
---
server:
port: 8083
spring:
profiles:test
Summarize
This article is here, I hope to give you help, but also hope that you can pay more attention to this site more content!