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 ...
随机推荐
- 接口自动化 [授客]基于python+Testlink+Jenkins实现的接口自动化测试框架V3.0
基于python+Testlink+Jenkins实现的接口自动化测试框架V3.0 by:授客 QQ:1033553122 博客:http://blog.sina.com.cn/ishou ...
- Android 7.0 新特性
Android7.0提供新功能以提升性能.生产效率和安全性. 关于Android N的性能改进,Android N建立了先进的图形处理Vulkan系统,能少的减少对CPU的占用.与此同时,Androi ...
- Apache Windows下Apache安装步骤
1.apache官网下载Apache HTTP Server服务器 我相信有些朋友刚用apache服务器时,都希望从官网上下载,而面对着官网上众多的项目和镜像以及目录,也许有点茫然.下面是具体步骤: ...
- JS 文本框格式化
页面: <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script> & ...
- Response()的对象
addCookie(Cookie cookie):这个方法是向Response容器中添加一个Cookie,然后服务器容器会自动的将这个Cookie回写给客户机的,至于Cookie的相关知识我们会在后面 ...
- [20181015]为什么是3秒.txt
[20181015]为什么是3秒.txt --//以前测试:连接http://blog.itpub.net/267265/viewspace-2144765/=>为什么是12秒.txt.--// ...
- 初学ubuntu命令
将我第一天学的内容做个笔记 ,方便日后查看 命令的使用: ls ls -a 显示所有文件 ls -l 显示文件的所有信息 cp 注意命令格式 /home/../temp/a /ho ...
- js 时间戳转时间格式
$("#showbidMessage").append(<span>' + ChangeDateFormat(rows[i].createTime) + '</s ...
- Linux: 软件包管理之rpm与yum [转]
软件包的安装和卸载时很平常的事,但在Linux上面却不简单..Linux的其中一个哲学就是一个程序只做一件事,并且做好.组合小程序来完成复杂的任务,这样做有很多好处,但是各个小程序之间往往会存在着复杂 ...
- 南邮ctf-web的writeup
WEB 签到题 nctf{flag_admiaanaaaaaaaaaaa} ctrl+u或右键查看源代码即可.在CTF比赛中,代码注释.页面隐藏元素.超链接指向的其他页面.HTTP响应头部都可能隐藏f ...