spring boot maven profiles,打包不同的配置文件
1. 在pom.xml添加
<profiles>
<profile>
<id>dev</id>
<properties>
<environment>dev</environment>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<environment>prod</environment>
</properties>
</profile> </profiles> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<!--打包时,指不要这些文件-->
<excludes>
<exclude>application-dev.properties</exclude>
<exclude>application-prod.properties</exclude>
</excludes>
</resource>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>application-${profileActive}.properties</include>
</includes>
</resource>
</resources>
</build>
2. 在 application.properties 增加 spring.profiles.active=@profileActive@
3. 使用 mvn clean package -P dev 打包,这样打包出的文件就不包含 application-prod.properties
注: 如果用 idea IDE , 运行的时候这里要选一下:

spring boot maven profiles,打包不同的配置文件的更多相关文章
- Spring Boot Maven Plugin打包异常及三种解决方法:Unable to find main class
[背景]spring-boot项目,打包成可执行jar,项目内有两个带有main方法的类并且都使用了@SpringBootApplication注解(或者另一种情形:你有两个main方法并且所在类都没 ...
- Spring boot(4)-应用打包部署
1.Spring Boot内置web spring Boot 其默认是集成web容器的,启动方式由像普通Java程序一样,main函数入口启动.其内置Tomcat容器或Jetty容器,具体由配置来决定 ...
- Spring Boot(十二):spring boot如何测试打包部署
Spring Boot(十二):spring boot如何测试打包部署 一.开发阶段 1,单元测试 在开发阶段的时候最重要的是单元测试了,springboot对单元测试的支持已经很完善了. (1)在p ...
- Spring Boot Maven Plugin(二):run目标
简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...
- 【转载】Spring boot学习记录(二)-配置文件解析
前言:本系列文章非本人原创,转自:http://tengj.top/2017/04/24/springboot0/ 正文 Spring Boot使用了一个全局的配置文件application.prop ...
- Spring Boot Maven Plugin(一):repackage目标
简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...
- Java Spring Boot VS .NetCore (七) 配置文件
Java Spring Boot VS .NetCore (一)来一个简单的 Hello World Java Spring Boot VS .NetCore (二)实现一个过滤器Filter Jav ...
- 微服务下 Spring Boot Maven 工程依赖关系管理
单体 Spring Boot Maven 工程 最基本的 pom.xml 包含工程信息.Spring Boot 父工程.属性配置.依赖包.构建插件 <?xml version="1.0 ...
- Spring Boot的Maven插件Spring Boot Maven plugin详解
Spring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Mave ...
随机推荐
- 手写koa-static源码,深入理解静态服务器原理
这篇文章继续前面的Koa源码系列,这个系列已经有两篇文章了: 第一篇讲解了Koa的核心架构和源码:手写Koa.js源码 第二篇讲解了@koa/router的架构和源码:手写@koa/router源码 ...
- PyQt(Python+Qt)学习随笔:QMainWindow的takeCentralWidget对QDockWidget作用案例图解
专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 QMainWindow的takeCentralWidget方法作用是将 ...
- 转:Http协议中Cookie详细介绍
Http协议中Cookie详细介绍 Cookie总是保存在客户端中,按在客户端中的存储位置,可分为内存Cookie和硬盘Cookie.内存Cookie由浏览器维护,保存在内存中,浏览器关闭后就消失了, ...
- git 常用命令 command 1.0(本地 local repository 对远程仓库 remote repository 的操作)
输入 q 退出 日志界面
- mvvm和mvc区别?
mvc和mvvm其实区别并不大.都是一种设计思想.主要就是mvc中Controller演变成mvvm中的viewModel. mvvm主要解决了mvc中大量的DOM 操作使页面渲染性能降低,加载速度变 ...
- 【题解】The Great Divide [Uva10256]
[题解]The Great Divide [Uva10256] 传送门:\(\text{The Great Divide [Uva10256]}\) [题目描述] 输入多组数据,每组数据给定 \(n\ ...
- 如何建一个SAM
部分改编自OI WIKI 先从一个简单的问题入手: 给定一个串,构造一个图,使其能够表示它的所有子串. 显然一个子串就是一个后缀的前缀.所以一个很显然的方式就是把所有后缀扔进trie里. 比如当前串是 ...
- 【题解】「P6771」[USACO05MAR]Space Elevator 太空电梯
P6771 这是一道很明显的 dp 问题. 首先 dp 最重要的三要素是:动态表示.动态转移.初始状态. 只要这三个要素搞明白了,基本就能把这题做出来了. solution 让我们来看看这题的动态表示 ...
- 使用MySQL乐观锁解决超卖问题
在秒杀系统设计中,超卖是一个经典.常见的问题,任何商品都会有数量上限,如何避免成功下订单买到商品的人数不超过商品数量的上限,这是每个抢购活动都要面临的难点. 1 超卖问题描述 在多个用户同时发起对同一 ...
- 20201204-3 opp编程好处
面向对象编程(Object-Oriented Programming )介绍 对于编程语言的初学者来讲, OOP不是一个很容易理解的编程方式,大家虽然都按老师讲的都知道0OP的三大特性是 继承.封装. ...