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 ...
随机推荐
- Implemented Energy-Conserving Hair Scattering Model from Weta Digital
I used to implement the Energy-Conserving Hair Scattering Model as the pre-calculation program, so t ...
- C++基础概述
阅读Android源码需要对C++基础语法有一定的认识,借此对C++做一个简单的语法认知. 1.数据类型 类型 关键字 布尔型 bool 字符型 char 整型 int 浮点型 float 双浮点型 ...
- C#:关于C#4中IEnumerable<out T>的理解
IEnumerable<out T>这个接口非常常见,它是最基础的泛型集合接口,表示可迭代的项的序列. 但是奇怪的是为什么泛型参数要带一个“out”? 经过一番资料查阅后,发现此“out” ...
- 生产者、消费者模型---Queue类
Queue队列在几乎每种编程语言都会有,python的列表隐藏的一个特点就是一个后进先出(LIFO)队列.而本文所讨论的Queue是python标准库queue中的一个类.它的原理与列表相似,但是先进 ...
- git上传中的排除的配置文件, git实际的操作代码;
git上传中的排除的配置文件: git实际的操作 在主目录建立.gitignore文件并输入以下保存: *.class #package file *.war *.ear #kdiff3 ignore ...
- html之CSS样式学习笔记
本文内容: 字体样式 文本样式 背景样式 尺寸样式 盒子模型 边框样式 边距样式 浮动布局 定位布局 [CSS3]伸缩布局 标签显示方式 列表样式 [CSS3]过渡样式 [CSS3]变换样式之2D变形 ...
- ros中自定义消息 报错 ImportError: No module named em
大家好,欢迎来到我的博客,之前写的都是比较松散的,鉴于工作的原因,之后的随笔将持续更新ROS以及linux使用方面的随笔,欢迎大家留言,相互学习 ——————————————————————————— ...
- logstash配置
input { #You must define a [type], otherwise you cannot get a field to cut. tcp { port => 5045 ty ...
- SMB协议原理抓包分析
SMB协议原理抓包分析 目录: 1.SMB概述 2.SMB原理 3.SMB配置 一.SMB概述 SMB(全称是Server Message Block)是一个协议名,可用于在计算机间共享文件.打印机. ...
- 制作U盘启动-----计算机经验
这期呢我就先不打算写关于C的文章,这次就先给大家写几篇关于电脑系统安装的计算机经验篇.希望各位接下来看了我几期的经验文章,你们也能在电脑系统报销之时能够让其满血复活. 制作U盘启动 下载制作U盘启动的 ...