常用的配置文件application.yml

本文详细介绍了Spring Boot中核心配置文件application.yml的使用,包括如何声明属性、层级结构、占位符引用等,帮助开发者更好地理解和配置Spring Boot应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

# 应用环境
# 公共配置
spring:
  profiles:
    active: dev
---
# 设置环境
# 生产环境
spring:
  profiles: pro
server:
  port: 80
---
# 开发环境
spring:
  profiles: dev
server:
  port: 81
---
# 测试环境
spring:
  config:
    activate:
      on-profile: test
server:
  port: 82

--------------------------------------------
  
server:
  port: 80

spring:
  datasource:
    druid:#连接池
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://localhost:3306/book?serverTimezone=UTC
      username: "root"
      password: "root"
  redis:#redis配置
    host: localhost
    port: 6379
    database: 0

mybatis-plus:
  global-config:
    db-config:
      table-prefix: tbl_    #设置所有表的通用前缀名称为tbl_
      id-type: auto         #设置主键id字段的生成策略为参照数据库设定的策略,当前数据库设置id生成策略为自增
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl   #查看MP运行日志
    
--------------------------------------------
#文件上传
spring:
  servlet:
    multipart:
      max-request-size: 2GB  # 上传文件总的最大值 默认10MB
      max-file-size: 1GB #单个文件最大值 默认10MB
--------------------------------------------
## 开启debug模式,输出调试信息,常用于检查系统运行状况
#debug: true

# 设置日志级别,root表示根节点,即整体应用日志级别
logging:
  level:
    root: info
    com.itheima.controller: debug

#设置日志模板格式
  pattern:
#    console: "%d - %m %n"
    console: "%d %clr(%p) --- [%16t] %clr(%-40.40c){cyan} : %m %n"

  file:
    name: server.log

  logback:
    rollingpolicy:
      max-file-size: 4KB
      file-name-pattern: server.%d{yyyy-MM-dd}.%i.log
--------------------------------------------
#发送邮件
# 应用名称
spring:
  application:
    name: springboot_mail
  mail:
    host: smtp.qq.com
    username: 2849019757@qq.com
    password: devttnkmjswndhdg
    default-encoding: UTF-8


server:
  port: 8080
--------------------------------------------
#mybatis,连接数据库
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/book
    username: root
    password: root
--------------------------------------------
spring:
  devtools:
    restart:
      #    不参与热部署
      exclude: static/**,public/**,config/application.yml
#      是否开启热部署,默认true
#      enabled: false

--------------------------------------------
#默认路径
spring.thymeleaf.prefix=classpath:/templates/
#后缀
spring.thymeleaf.suffix=.html
#模板格式
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false

--------------------------------------------
#开启模板缓存(默认值:true)
spring.thymeleaf.cache=false
#Content-Type 的值(默认值:text/html)
spring.thymeleaf.content-type=text/html
#开启MVC Thymeleaf 视图解析(默认值:true)
spring.thymeleaf.enabled=true
#模板编码
spring.thymeleaf.encoding=UTF-8
#要运用于模板之上的模板模式,
spring.thymeleaf.mode=HTML5
#在构建URL时添加到视图名称前的前缀(默认值:classpath:/templates/
spring.thymeleaf.prefix=classpath:/templates/
#在构建URL时添加到视图名称后的后缀(默认值:.html
spring.thymeleaf.suffix=.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值