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值

猜你喜欢

转载自www.cnblogs.com/cppdy/p/10053479.html
今日推荐