spring boot多环境配置 直接上代码

时间:2023-01-05 00:55:08

spring:
  profiles:
    active: test
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/dispatch
    username: root
    password: huahai
---
#开发环境
spring:
  profiles: dev
server:
  port: 8081
---
#测试环境
spring:
  profiles: test
server:
  port: 8082
---
#生产环境
spring:
  profiles: prod
server:
  port: 8080