常⻅的配置⽂件格式
xml、properties、json、yaml
Springboot⾥⾯常⽤xx.yml
YAML(Yet Another Markup Language)
写 YAML 要⽐写 XML 快得多(⽆需关注标签或引号) 使⽤空格 Space 缩进表示分层,不同层次
之间的缩进可以使⽤不同的空格数⽬
注意:key后⾯的冒号,后⾯⼀定要跟⼀个空格,树状结构
server:
port: 8080 //设置启动端⼝号为8080
house:
family:
name: Doe
parents:
- John
- Jane
children:
- Paul
- Mark
- Simone
address:
number: 34
street: Main Street
city: Nowheretown
zipcode: 12345
Springboot⾥⾯常⽤ xx.properties(推荐)
Key=Value格式
语法简单,不容易出错
server.port=8082
#session失效时间,30m表示30分钟
server.servlet.session.timeout=30m
# Maximum number of connections that the server accepts and processes at
any given time.
server.tomcat.max-connections=10000
# Maximum size of the HTTP post content.
server.tomcat.max-http-post-size=2MB
server.tomcat.max-http-form-post-size=2MB
# Maximum amount of worker threads
server.tomcat.max-threads=200
官方文档配置
https://docs.spring.io/spring-boot/docs/2.3.0.BUILD-SNAPSHOT/reference/htmlsingle/#
core-properties
如果需要修改,直接复制对应的配置⽂件加到application.properties⾥⾯,⼀般不需要调整