SpringBoot - 多环境搭建

// application.yml

spring:
  profiles:
    active: dev
// application-dev.yml

server:
  port: 8081
  servlet:
    context-path: /luckymoney

limit:
  minMoney: 0.01
  maxMoney: 9999
  description: 最少要发${limit.minMoney}元, 最多${limit.maxMoney}元

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/luckymoney?characterEncoding=utf-8
    username: root
    password: 123456
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
// application-prod.yml

server:
  port: 8081
  servlet:
    context-path: /luckymoney

limit:
  minMoney: 1
  maxMoney: 9999
  description: 最少要发${limit.minMoney}元, 最多${limit.maxMoney}元
  • 多环境配置,项目部署时,切换 启动项目,项目部署时候,设置配置文
    java -jar -Dspring.profiles.active=prod target/luckymoney-0.0.1-SNAPSHOT.JAR
发布了909 篇原创文章 · 获赞 1770 · 访问量 87万+

猜你喜欢

转载自blog.csdn.net/Dream_Weave/article/details/105360260