SpringBoot通过配置文件application.yml/application.properties可以完成对大部分组件的控制和配置,所以为了快速使用SpringBoot,我们需要对所有的配置项目有一个概览,本文就是做一些解释和翻译而已。其中最完整的配置资料请参考
https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html
官方的配置文档
下面列出一些我个人觉得还比较常见的配置
1、banner的配置
banner.charset=UTF-8
banner.location=classpath:banner.txt
2、profiles的配置
spring.profiles.active = 当前要激活使用的peofile配置,如:填写dev的话,Springboot启动时候会自动查找application-dev.properties,作为配置文件启动。
3、Application Settings
spring.main.web-enviromenet
spring.main.show-banner = true //是否展示启动banner
4、logging 日志相关
logging.path = /var/logs
logging.file = myapp.log
logging.config = 配置文件(默认:classpath:logback.xml)
logging.level.* = . //配置包体的日志打印级别,可以配置多项
5、spring.application.name = 应用id
6、Spring内嵌的服务器配置
server.port = 8080
server.address = 绑定一个IP
server.session-timeout = 36000 会话过期
server.context-path = / 访问路径
server.tomcat.max-threads = 0
server.tomcat.uir-encoding = UTF-8
7、Spring MVC 的配置
spring.mvc.locale =
spring.mvc.date-format = 日期格式比如:dd/MM/yyyy
spring.view.prefix =
spring.view.suffix =
8、文件上传配置
multipart.enabled = true
multipart.file-size-threshold = 0 文件尺寸阈值,0表示不限制
multipart.location = 上传文件位置
multipart.max-file-size = 上传文件最大位置
multipart.max-request-size = 10Mb 最大请求尺寸
9、http encoding
spring,http.encoding.charset = UTF-8
spring.http.encoding.enable = true
spring.http.encoding.force = true
10、Spring Security
|
| 默认的用户名称 |
| 默认的密码,如果不配置则在启动时随机生成并打印 | |
| 授权给上面的账户对应的角色权限. | |
|
| 默认缓存 | Session 存储类型 |
| Session 过期时间 |
11、关于JPA的配置
| Target database to ope rate on, auto-detected by default. Can be alternat ively set using the "databasePlatform" property. | |
| Name of the target database to operate on, auto-detected by default. Can be alternatively set using the "Database" enum. | |
|
| Whether to initialize the schema on startup. |
| DDL mode. This is actually a shortcut for the "hibernate.hbm2ddl.auto" property. Defaults to "create-drop" when using an embedded database and no schema manager was detected. Otherwise, defaults to "none". | |
| Fully qualified name of the implicit naming strategy. | |
| Fully qualified name of the physical naming strategy. | |
| Whether to use Hibernate's newer IdentifierGenerator for AUTO, TABLE and SEQUENCE. This is actually a shortcut for the "hibernate.id.new_generator_mappings" property. When not specified will default to "true". | |
| Mapping resources (equivalent to "mapping-file" entries in persistence.xml). | |
|
| Register OpenEntityManagerInViewInterceptor. Binds a JPA EntityManager to the thread for the entire processing of the request. |
| Additional native properties to set on the JPA provider. | |
|
| 是否展示SQL |