springboot分环境打包(maven动态选择环境)
分环境打包核心点:spring.profiles.active
pom.xml中添加:
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<logback.loglevel>DEBUG</logback.loglevel>
<spring.profiles.active>dev</spring.profiles.active>
<profileActive>dev</profileActive>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<logback.loglevel>INFO</logback.loglevel>
<spring.profiles.active>test</spring.profiles.active>
<profileActive>test</profileActive>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<logback.loglevel>INFO</logback.loglevel>
<spring.profiles.active>prod</spring.profiles.active>
<profileActive>prod</profileActive>
</properties>
</profile>
</profiles>
resources目录下的配置文件:

其中,向application.yml文件中添加:
spring:
profiles:
active: @profileActive@
完成后,看看pom.xml文件中是有build模块(一般创建springboot项目会在pom.xml文件下自动生成),如果没有添加:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
然后再Terminal控制台输入maven打包命令:
- 选择dev环境(默认):
mvn clean package
- 选择test环境:
mvn clean package -P test
- 选择prod环境:
mvn clean package -P prod
springboot分环境打包(maven动态选择环境)的更多相关文章
- Windows环境下maven 安装与环境变量配置
Maven是一个项目管理的Java 工具,在JavaEE中,我们可以使用Maven方便地管理团队合作的项目,现在我们在学习JavaEE框架,使用Maven可以管理类库,有效方便地供团队中的其他人员使用 ...
- angular8 配置 测试环境打包指令 生成测试环境包指令
1.angular.json 文件中在architect 下添加 buildTest指令 距离位置 projects => (你的项目名称) => architect 下和 build 指 ...
- spring-boot分环境打包为tar包
1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...
- spring-boot分环境打包为war包
1.启动类修改 @EnableSwagger2 @SpringBootApplication public class CustWebAcApplication extends SpringBootS ...
- spring-boot分环境打包为jar包
1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...
- vue3.0+vite+ts项目搭建-分环境打包(四)
分环境打包配置 新建.env.dev(或者.env) VITE_NODE_ENV = 'dev' VITE_HOST = 'http://local.host.com' 执行yarn dev ,控制台 ...
- Spring boot项目分环境Maven打包,动态配置文件,动态配置项目
Spring boot Maven 项目打包 使用Maven 实现多环境 test dev prod 打包 项目的结构 在下图中可用看出,我们打包时各个环境需要分开,采用 application-环境 ...
- 使用Maven分环境打包:dev sit uat prod
使用Maven管理的项目,经常需要根据不同的环境打不同的包,因为环境不同,所需要的配置文件不同,比如database的连接信息,相关属性等等. 在Maven中,我们可以通过P参数和profiles元素 ...
- 用maven按环境打包SpringBoot的不同配置文件
利用maven按环境打包SpringBoot的不同配置文件 application-dev.properties对应开发环境 application-test.properties对应测试环境 app ...
随机推荐
- bzoj 1288: Neighbours
Description 很久以前, 有一个小小的国度, 为了方便, 我们可以把它想象为一个大大的矩形, 矩形的左下角为(0, 0), 右上角为(w, h), 共有(w + 1) * (h + 1)个整 ...
- 学习笔记之Redis
Redis https://redis.io/ redis.cn http://www.redis.cn/ Azure Redis Cache Documentation - Tutorials, A ...
- 在Linux 系统 Latex安装 使用入门教程
来源: http://blog.chinaunix.net/u/25605/showart_2100398.html 入门介绍好文:TeX.LaTeX.TeXLive 小结 笔记详情:http://v ...
- 如何在一个js文件中引入另外的js文件
例如想要在a.js中引用b.js.c.js和d.js document.write("<script language='javascript' src='b.js'></ ...
- java 总结代码块
判断str2在str中出现了多少次: //msg: // // 世界上最痛苦的事 莫过于有眼睛却发现不了美 有耳朵却不会欣赏音乐 有心灵却无法理解什么是最真 // 世界上最痛苦的事 莫过于错过了不该错 ...
- Java 集合 线程安全
Java中常用的集合框架中的实现类HashSet.TreeSet.ArrayList.ArrayDeque.LinkedList.HashMap.TreeMap都是线程不安全的,如果多个线程同时访问它 ...
- 第6章 进程控制(3)_wait、exec和system函数
5. 等待函数 (1)wait和waitpid 头文件 #include <sys/types.h> #include <sys/wait.h> 函数 pid_t wait(i ...
- no_unnest,push_subq,push_pred的用法 (转)
常常有人把这三个hint搞混,主要是因为对三种重写原理不清楚.特总结如下.(实验环境为10204)1. no_unnest, unnestunnest我们称为对子查询展开,顾名思义,就是别让子查询孤单 ...
- linux操作系统3 vi编辑器
知识内容: 1.Linux基础命令复习 2.vi模式和基本操作 3.vi常用快捷键 一.Linux基础命令复习 目录(文件夹)操作 cd 进入目录 (tab自动补全) pwd 查看当前目录 mkdir ...
- UVA375
题意: 已知等腰三角形的高H,底边长B,这时有一个内切圆C, 以内切圆C和长度为B对应的角的角平分线的交点做切线. 切线与角平分线相交,此时切线,和俩边又会出现一个小的等腰三角形,也有一个小的内切圆C ...