Maven的porfile与SpringBoot的profile结合使用详解
一、思路
示例一:
maven打包命令为 mvn clean package -P test
那么application.properties里面的spring.profiles.active值就是maven中 id为test的profile的activatedProperties参数值
示例二:
maven打包命令为 mvn clean package -P product
那么application.properties里面的spring.profiles.active值就是maven中 id为product的profile的activatedProperties参数值
示例一:
maven打包命令为 mvn clean package -P test
那么application.properties里面的spring.profiles.active值就是maven中 id为test的profile的activatedProperties参数值
示例二:
maven打包命令为 mvn clean package -P product
那么application.properties里面的spring.profiles.active值就是maven中 id为product的profile的activatedProperties参数值
二、案例
(1)项目结构介绍

(2)pom文件中配置maven的profile
<profiles>
<profile>
<!-- 开发 -->
<id>develop</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<activatedProperties>develop</activatedProperties>
</properties>
</profile>
<profile>
<!-- 测试 -->
<id>fuy</id>
<properties>
<activatedProperties>fuy</activatedProperties>
</properties>
</profile>
<profile>
<!-- 生产 -->
<id>production</id>
<properties>
<activatedProperties>production</activatedProperties>
</properties>
</profile>
</profiles>
x
<profiles>
<profile>
<!-- 开发 -->
<id>develop</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<activatedProperties>develop</activatedProperties>
</properties>
</profile>
<profile>
<!-- 测试 -->
<id>fuy</id>
<properties>
<activatedProperties>fuy</activatedProperties>
</properties>
</profile>
<profile>
<!-- 生产 -->
<id>production</id>
<properties>
<activatedProperties>production</activatedProperties>
</properties>
</profile>
</profiles>
(3)application.properties中的配置
spring.profiles.active=@activatedProperties@
spring.profiles.active=@activatedProperties@
(4)如何打包
(5)效果图

三、小结
四、参考链接
Maven的porfile与SpringBoot的profile结合使用详解的更多相关文章
- profile的使用详解
前言 在开发过程中,我们的项目会存在不同的运行环境,比如开发环境.测试环境.生产环境,而我们的项目在不同的环境中,有的配置可能会不一样,比如数据源配置.日志文件配置.以及一些软件运行过程中的基本配置, ...
- maven之(六)setting.xml的配置文件详解
setting.xml配置文件 maven的配置文件settings.xml存在于两个地方: 1.安装的地方:${M2_HOME}/conf/settings.xml 2.用户的目录:${user.h ...
- Maven使用笔记(四)pom.xml配置详解
pom.xml文件配置详解 --声明规范 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=" ...
- SpringBoot第二篇:配置文件详解一
作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/10837594.html 版权声明:本文为博主原创文章,转载请附上博文链接! 前言 Sprin ...
- IntelliJ IDEA 2017版 spring-boot加载jsp配置详解(详细图文实例)
一.创建项目 (File--->New-->Project) 2.项目配置内容 3.选择配置项目的Group包名,Artifact项目名称 4.选择项目类型为web类型 5.创建成功,点击 ...
- SpringBoot与Mybatis整合实例详解
介绍 从Spring Boot项目名称中的Boot可以看出来,SpringBoot的作用在于创建和启动新的基于Spring框架的项目,它的目的是帮助开发人员很容易的创建出独立运行的产品和产品级别的基于 ...
- SpringBoot入门及YML文件详解
SpringBoot 简介 微框架,与 Spring4 一起诞生,基于约定.生来为了简化 spring 的配置 优点 可以快速的上手,整合了一些子项目(开源框架或者第三方开源库) 可以依赖很少的配置快 ...
- springboot(四):thymeleaf使用详解
在上篇文章springboot(二):web综合开发中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thymeleaf的使用.thymeleaf 是新一代的模板引擎,在spring4. ...
- SpringBoot (四) :thymeleaf 使用详解
原文出处: 纯洁的微笑 在上篇文章< springboot(二):web综合开发 >中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thymeleaf的使用.thymele ...
随机推荐
- Java之static作用的全方位总结
1.深度总结 引用一位网友的话,说的非常好,如果别人问你static的作用:如果你说静态修饰 类的属性 和 类的方法 别人认为你是合格的:如果是说 可以构成 静态代码块,那别人认为你还可以: 如果你说 ...
- Android 内存管理中的 Shallow heap Retained heap
所有包含Heap Profling功能的工具(MAT,Yourkit,JProfiler,TPTP等)都会使用到两个名词,一个是Shallow heap Size,另一个是 Retained heap ...
- [Python][小知识][NO.4] wxPython 字体选择对话框(O.O 不知道放到那里就放到这个分类的)
1.前言 O.O 前两天回家浪了两天,断更了 哎~~~ o.o 有时候,有木有想改标签或编辑框中内容的字体呀?(o.o 反正我是没有). wxpython也可以说是所在的操作系统,有字体选择器,给我们 ...
- centos7安装jdk环境
有时候安装一些软件或者服务都需要jdk环境,今天就在centos上安装最新的jdk环境. 检测历时安装 1.查看Linux自带的JDK是否已安装 # java -version 2.查看JDK信息 # ...
- DPA从DPA 10.0.352升级到DPA 11.0.373
1: 解压安装文件SolarWinds-DPA-11.0.373-64bit.tar.gz [root@lnxmonitor tmp]# tar -xzvf SolarWinds-DPA-11.0.3 ...
- Spring MVC HelloWorld入门及运行机制 (一)
完整的项目案例: springmvc.zip 介绍 SpringMVC是一款Web MVC框架. 它跟Struts框架类似,是目前主流的Web MVC框架之一. 文章通过实例来介绍SpringMVC的 ...
- sql视图显示数据不对应
出现这样的原因是修改了表的结构,没有重新编译视图,这种情况出现的几率很少,并不是没有. 解决方法:重新编译一下该视图. 视图是一个虚表,是从一个或几个基本表(或视图)中导出的表,在系统的数据字典中仅存 ...
- NPOI导入导出Excel工具类
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Ref ...
- UGUI ContentSizeFitter之Button根据Text自适应
环境 Unity3D 5.3.6f1 练习地址:https://github.com/zhaoqingqing/UGUIDemo 布局放在Layout文件夹 文档:https://docs.unit ...
- 用beamoff给VMware的Mac OS X 10.10.x加速
前言 今天刚在VMware里装了个Yosemite,然后测试了下看电影,真j8卡,试了下在vm里打开3d加速,然并卵,直接显示不能打开3d加速,然后找了下发现有个vga的什么软件,是vmware里的显 ...