如何基于弹簧轮廓加载属性文件 [英] How to load property file based on spring profiles
本文介绍了如何基于弹簧轮廓加载属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建项目架构以支持多种环境.借助spring的
How to create project architecture to support multiple envionment. Each environment will have different datasource from different property file like(dev-propertfile,test-propertyFil,Production-propertyfile) with help of spring's
org.springframework.core.env.Environment;
推荐答案
我将逐步介绍Spring引导应用程序的过程.
I'll give step by step procedure for Spring boot applications.
- 在/src/main/resources/application.properties 内提及 spring.profiles.active = dev (或产品)
- 创建/src/main/resources/application-dev.properties 并在此处提供您的自定义开发配置.
- 创建/src/main/resources/application-prod.properties ,并在此处提供自定义的产品配置.
- Inside /src/main/resources/application.properties mention spring.profiles.active=dev (or Prod)
- Create /src/main/resources/application-dev.properties and give your custom dev configurations here.
- Create /src/main/resources/application-prod.properties and give your custom prod configurations here.
运行.
这篇关于如何基于弹簧轮廓加载属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文