SpringBoot优雅配置多环境yml配置文件

实际开发中,会有很多种环境的切换,本地,测试,生产等,各环境的信息都可能不同,这时候需要配置多环境的yml文件,如下:

1:配置一个主的application.yml文件

spring:
  profiles:
#  环境分支:dev本地分支|test测试分支|prod生产分支
    active: test

# 配置pagehelper参数
pagehelper:
  helperDialect: mysql
  reasonable: true
  supportMethodsArguments: true
  params: count=countSql




 

2:配置本地的yml:命名以:application-dev.yml

#用于配置开发坏境信息
#配置服务端口号
server:
  port: 8080
  servlet:
    context-path: /path
    session:
      timeout: 1800s
# 配置数据库信息
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/***?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
#Mybatis的mapper.xml文件位置
mybatis:
  mapper-locations: classpath:mapper/*.xml
#配置日志输出位置
logging:
  file:
    path: D:\log

其他环境的yml文件类似上面,自己根据实际情况进行配置即可!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值