SpringBoot二十七:多环境配置

相关知识(简述)

SpringBoot profile:

SpringBoot允许我们在配置文件(以application.properties示例)中通过配置spring.profiles.active=xxx,来对应激活application-xxx.properties配置,这就是SpringBoot profile。

Maven profile:

Maven允许我们在配置文件(项目pom.xml文件或maven的settings.xml文件)中配置多个profile,并通过mvn指令或触发器指定激活那个(或哪些)profile。
注:关于maven profile的相关知识考https://blog.csdn.net/justry_deng/article/details/100537571

SpringBoot profile整合Maven profile实现多环境配置、依赖自动切换

第一步:准备SpringBoot的profile(即:准备相关配置文件)。
在这里插入图片描述
第二步:根据自己的实际需求,在pom.xml中,准备Maven 的profile。
在这里插入图片描述
第三步:将Maven profile与SpringBoot profile关联起来。
在这里插入图片描述
在这里插入图片描述
第四步:在系统配置文件中application.properties中,动态获取pom.xml里的激活环境标识。
在这里插入图片描述
第五步:测试一下。

clean install -P dev-id
clean install -P test-id
clean install -P pre-id
clean install -P prod-id

参考:https://blog.csdn.net/justry_deng/article/details/100544886

代码托管:springboot_profile

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值