从零开始SpringBoot2.x【三】全面认识SpringBoot的application.properties

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

spring.security.user.name

user

默认的用户名称

spring.security.user.password

 

默认的密码,如果不配置则在启动时随机生成并打印

spring.security.user.roles

 

授权给上面的账户对应的角色权限.

 

pring.session.store-type

默认缓存

Session 存储类型

spring.session.timeout

 

Session 过期时间

 

11、关于JPA的配置

ring.jpa.database

 

Target database to ope

rate on, auto-detected by default. Can be alternat

ively set using the "databasePlatform" property.

spring.jpa.database-platform

 

Name of the target database to operate on, auto-detected by default. Can be alternatively set using the "Database" enum.

spring.jpa.generate-ddl

false

Whether to initialize the schema on startup.

spring.jpa.hibernate.ddl-auto

 

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".

spring.jpa.hibernate.naming.implicit-strategy

 

Fully qualified name of the implicit naming strategy.

spring.jpa.hibernate.naming.physical-strategy

 

Fully qualified name of the physical naming strategy.

spring.jpa.hibernate.use-new-id-generator-mappings

 

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".

spring.jpa.mapping-resources

 

Mapping resources (equivalent to "mapping-file" entries in persistence.xml).

spring.jpa.open-in-view

true

Register OpenEntityManagerInViewInterceptor. Binds a JPA EntityManager to the thread for the entire processing of the request.

spring.jpa.properties.*

 

Additional native properties to set on the JPA provider.

spring.jpa.show-sql

false

是否展示SQL
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值