springboot多环境开发

这篇博客探讨了如何在Spring框架中管理多个环境的配置,包括yaml和properties两种格式的应用。内容涉及主动激活不同环境(如生产、开发、测试)的配置,以及各个环境下的服务器端口设置,旨在实现灵活的环境切换和部署策略。

yml版

#应用环境
#公共配置
spring:
  profiles:
    active: test
---
#设置环境
#生产环境
spring:
  config:
    activate:
      on-profile: prod
server:
  port: 80
---
#开发环境
spring:
  config:
    activate:
      on-profile: dev
server:
  port: 8001
---
#测试环境
spring:
  config:
    activate:
      on-profile: test
server:
  port: 8002

多配制文件版
1.主配置文件application.yml`

spring:
  profiles:
    active: test

2.环境分类配置文件application-prod.yml

server:
  port: 8083

3.环境分类配置文件application-dev.yml

server:
  port: 8004

4.环境分类配置文件application-test.yml

server:
  port: 8005

properties版

1.主配置文件application.properties

spring.profiles.active=test

2.环境分类配置文件application-prod.properties

server.port=9001

3.环境分类配置文件application-dev.properties

server.port=9002

4环境分类配置文件application-test.properties

server.port=9003
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值