SpringBoot2.x常见配置文件形式

233 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

常见的配置文件格式

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

官方文档配置查找表

docs.spring.io/spring-boot…

如果需要修改,直接复制对应的配置文件加到application.properties⾥面,一般不需要调整