1.多profile文件形式

主配置文件编写时, 文件名可以是application-{profile}.properties/yml

默认使用的application.properties的配置.

2.多profile文档块模式

yml支持多文档块模式

可以通过启动时端口号判断启用的环境.

3.激活方式

命令行

配置文件中指定

jvm参数

另:通过程序获取profile的值

https://blog.csdn.net/Fmuma/article/details/82787500

使用profile帮我解决了不同环境使用不同配置的问题,那么如果我们需要在代码中获取这个profile的值怎么处理呢?

@Component
public class ProfileUtil implements ApplicationContextAware { private static ApplicationContext context = null; @Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.context = applicationContext;
} // 获取当前环境参数 exp: dev,prod,test
public static String getActiveProfile() {
String []profiles = context.getEnvironment().getActiveProfiles();
if( ! ArrayUtils.isEmpty(profiles)){
return profiles[0];
}
return "";
}
}

最新文章

  1. c# 获取项目的根目录
  2. 找到多个与名为“Login”的控制器匹配的类型
  3. Kmin
  4. asp.net 微信企业号办公系统-流程设计--流程步骤设置-数据设置
  5. Linux 配置本地yum源
  6. Python3 学习第三弹:异常情况如何处理?
  7. UVALive-4287 Proving Equivalences 有向图的强连通分量+缩点
  8. HW2.22
  9. 转载 VC 2010下安装OpenCV2.4.4
  10. POJ2782:Bin Packing
  11. java 基础知识四 流程控制
  12. javascript---split 和 join 的区别
  13. springboot(五)过滤器和拦截器
  14. LeetCode算法题-Diameter of Binary Tree(Java实现)
  15. python学习第21天
  16. python数据库多字段插入
  17. #20175120彭宇辰-实验一《Java开发环境的熟悉》实验报告
  18. XML技术思想
  19. python异常处理的两种写法
  20. IIS7部署网站遇到的问题

热门文章

  1. YUV视频格式详解(翻译自微软文档)
  2. vagrant 无法挂载共享目录
  3. Windows Server 2012 R2 配置IIS
  4. NumPy 之 存储文件和线性代数
  5. windows10安装redis
  6. 最常用MySql数据库备份恢复
  7. QT,QT/E,Qtopia,qt creator的联系与区别
  8. python __getattr__ & __getattribute__ 学习
  9. Ecshop 2.x-3.x RCE漏洞复现
  10. Kubernetes架构及相关服务详解