从零开始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

你可能感兴趣的:(Spring,JPA)