SpringBoot中 application.yml /application.properties常用配置介绍

本文详细介绍了SpringBoot中`application.yml`和`application.properties`的常用配置,包括服务端口、服务名称、容器配置、连接池、SQL连接、信息配置、模板引擎等。特别指出配置项的规则,如‘.’分隔变为树状结构,冒号后跟空格,以及删除原`application.properties`后执行Maven清理安装。
摘要由CSDN通过智能技术生成

SpringBoot中 application.yml /application.properties常用配置介绍

项目中常见配置:
服务端口
服务名称
容器: 类型 如tomcat、undertow 程池大小 请求日志和目录
连接池配置:
sql连接配置
info配置:
模板配置
资源配置

# Tomcat
server:
  tomcat:
    uri-encoding: UTF-8
    max-threads: 1000
    min-spare-threads: 30
  port: 10444
  servlet:
    context-path: /admin
#文件上传文件夹
upload:
    base:
        dir: D:/piyan/upload
    basedir: E:/cms


spring:
  resources:
    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${upload.base.dir}
  profiles:
    active: dev
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
  servlet:
    multipart:
      max-file-size: 4096MB
      max-request-size: 4096MB
      enabled: true
  freemarker:
    suffix: .html
    request-context-attribute: request
    cache: false
  devtools:
    restart:
      enabled: false
      #additional-paths: src/main/java
      exclude: WEB-INF/*


cmodes:
  redis:
    open: true  # 是否开启redis缓存  true开启   false关闭
  shiro:
    redis: true # true表示shiro session存到redis里,需要开启redis,才会生效【分布式场景】

#mybatis
mybatis-plus:
  mapper-locations: classpath*:mapper/**/*.xml
  #实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: cn.cmodes.modules.*.entity
  global-config:
    #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
    id-type: 2
    #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
    field-strategy: 2
    #驼峰下划线转换
    db-column-underline: true
    #刷新mapper 调试神器
    refresh-mapper: true
    #数据库大写下划线转换
    #capital-mode: true
    # Sequence序列接口实现类配置
    #key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
    #逻辑删除配置
    logic-delete-value: -1
    logic-not-delete-value: 0
    #自定义填充策略接口实现
    #meta-object-handler: com.baomidou.springboot.xxx
    #自定义SQL注入器
    sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: false
    call-setters-on-nulls: true


logging:
  level: debug
  level.cn.cmodes: debug
  path: logs/
  file: admin.log
mvc
spring.mvc.async.request-timeout
设定async请求的超时时间,以毫秒为单位,如果没有设置的话,以具体实现的超时时间为准,比如tomcat的servlet3的话是10秒.
spring.mvc.date-format
设定日期的格式,比如dd/MM/yyyy.
spring.mvc.favicon.enabled
是否支持favicon.ico,默认为: true
spring.mvc.ignore-default-model-on-redirect
在重定向时是否忽略默认model的内容,默认为true
spring.mvc.locale
指定使用的Locale.
spring.mvc.message-codes-resolver-format
指定message codes的格式化策略(PREFIX_ERROR_CODE,POSTFIX_ERROR_CODE).
spring.mvc.view.prefix
指定mvc视图的前缀.
spring.mvc.view.suffix
指定mvc视图的后缀.
messages
spring.messages
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值