常⻅的配置⽂件格式

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⾥⾯,⼀般不需要调整

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐