SpringBoot ——配置檔案多環境配置

ldear發表於2017-08-31

application.yml

spring:

# 啟動載入配置版本
  profiles:
    active: dev
例子 application-{dev}.yml


application-dev.yml

# Tomcat配置
server:
  context-path: /demo
  port: 888
  session:
    timeout: 36000
  tomcat:
    uri-encoding: UTF-8
    max-threads: 1000
    min-spare-threads: 100
  connection-timeout: 20000
#資料來源
spring:
  datasource:
    dbcp2:
      max-idle: 100
      min-idle: 50
      initial-size: 50
      max-total: 4000
    type: org.apache.commons.dbcp2.BasicDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false&serverTimezone=GMT%2b8
    username:
    password:

application-prod.yml



啟動時載入 application.yml ---》dev.yml--》tomcat -->datasource



相關文章