美文网首页Spring Boot 企业级实战
Spring Boot 项目常用配置

Spring Boot 项目常用配置

作者: 固安李庆海 | 来源:发表于2018-01-06 16:03 被阅读31次

    数据源及连接池配置

    spring.datasource.druid.url=jdbc:mysql://192.168.10.58:3306/edu?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
    spring.datasource.druid.username =root
    spring.datasource.druid.password =infcn123
    spring.datasource.druid.driver-class-name=com.mysql.jdbc.Driver
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    spring.jpa.database=MYSQL
    spring.jpa.show-sql =true
    spring.datasource.druid.filters=stat
    spring.datasource.druid.connection-properties=config.decrypt=true
    spring.datasource.druid.initial-size=8
    spring.datasource.druid.min-idle=5
    spring.datasource.druid.max-active=10
    spring.datasource.druid.time-between-eviction-runs-millis=60000
    spring.datasource.druid.min-evictable-idle-time-millis=600000
    spring.datasource.druid.validation-query=SELECT 'x'
    spring.datasource.druid.pool-prepared-statements=true spring.datasource.druid.max-pool-prepared-statement-per-connection-size=20
    #配置hibernate的命名策略
    spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    

    文件上传配置

    spring.http.multipart.enabled=true
    spring.http.multipart.file-size-threshold=0
    spring.http.multipart.location=d:/tmp
    spring.http.multipart.max-file-size=50Mb
    spring.http.multipart.max-request-size=100Mb
    

    mvc配置

     spring.mvc.view.prefix=/WEB-INF/jsp/
     spring.mvc.view.suffix=.jsp
    

    Jackson相关设置

    #日期格式化
    spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
    spring.jackson.joda-date-time-format=yyyy-MM-dd HH:mm:ss
    #时区设置
    spring.jackson.time-zone=GMT+8
    spring.jackson.serialization.fail-on-empty-beans=false
    

    取消身份认证

    security.basic.enabled=false
    

    中文乱码解决

    spring.http.encoding.force=true
    spring.http.encoding.charset=UTF-8
    spring.http.encoding.enabled=true
    server.tomcat.uri-encoding=UTF-8
    

    相关文章

      网友评论

        本文标题:Spring Boot 项目常用配置

        本文链接:https://www.haomeiwen.com/subject/rgmynxtx.html