1. 程式人生 > >SpringBoot多環境區分

SpringBoot多環境區分

1、修改application.yml配置檔案

spring:
  profiles:
    active: cppdy
  datasource: 
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8
    username: root
    password: root
  thymeleaf:
    mode: HTML5
    encoding: UTF-8
    content-type: text/html
name: cppdy123

2、建立application-cppdy.yml配置檔案

name: cppdy222

3、訪問測試方法讀取的是application-cppdy.yml中的name值