SpringBoot 配置文件区分环境

  sre

5fdc1f3ade4e68965.jpg_fo742.jpg

application.yml

# 端口
server:
  port: 8080

spring:
  application:
    # 应用名称
    name: test1
  profiles:
    # 使用的配置文件
    active: prod

application-dev.yml

  datasource:
    primary:
      jdbc-url: jdbc:mysql://localhost:3306/dbname
      #url: jdbc:mysql://localhost:3306/dbname
      username: root
      password: 123456
      driver-class-name: com.mysql.jdbc.Driver

application-prod.yml

  datasource:
    primary:
      jdbc-url: jdbc:mysql://192.168.0.2:3306/dbname
      #url: jdbc:mysql://192.168.0.2:3306/dbname
      username: root
      password: 12345678
      driver-class-name: com.mysql.jdbc.Driver

LEAVE A COMMENT

Captcha Code