Spring boot 分环境部署
一.如果配置文件为:application.properties时
1.application.properties用于填些公共文件
以下为不同环境的配置文件需要单独配置
application-dev.properties
application-prod.properties
application-test.properties
application.yml用于填些公共文件
以下为不同环境的配置文件需要单独配置
application-dev.yml
application-prod.yml
application-test.yml
2.application.properties内配置打包运行的环境
spring.profiles.active=@profiles.active@
application.ym配置文件中配置
# 指定执行环境
spring:
profiles:
active: @package.environment@
3.配置pom.xml打包配置
<!-- maven不同环境配置 -->
<profiles>
<!-- 开发环境 -->
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
</properties>
<activation>
<!---指定默认激活->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 演示环境 -->
<profile>
<id>dev</id>
<properties>
<profiles.active>dev</profiles.active>
</properties>
</profile>
<!-- 生产环境 -->
<profile>
<id>prod</id>
<properties>
<profiles.active>prod</profiles.active>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.tkgm.api.StartAppApplication</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<!-- resources是对配置文件资源的处理,使用见前言部分 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.class</include>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>application-prod.properties</exclude>
<exclude>application-dev.properties</exclude>
<exclude>application-test.properties</exclude>
<exclude>application.properties</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<!--读取打包命令中指定的环境-->
<filtering>true</filtering>
<includes>
<include>application.properties</include>
<include>application-${profiles.active}.properties</include>
<include>log4j2.properties</include>
<include>jpush.properties</include>
<include>apiurl.properties</include>
</includes>
</resource>
</resources>
</build>
4.打包命令:打包查看jar打包结果
mvn clean compile package -Dmaven.test.skip=true -Pdev
Spring boot 分环境部署的更多相关文章
- Spring Boot 多环境部署
再简单的应用系统,通常都有两个环境——开发环境和线上环境.大型的企业应用还会有更多的环境,比如测试环境.准线上环境.演示环境等.应用的版本也可能对应了多个环境,比如1.0版本的演示环境.2.0版本的演 ...
- Spring Boot入门系列(十五)Spring Boot 开发环境热部署
在实际的项目开发过中,当我们修改了某个java类文件时,需要手动重新编译.然后重新启动程序的,整个过程比较麻烦,特别是项目启动慢的时候,更是影响开发效率.其实Spring Boot的项目碰到这种情况, ...
- Spring boot+RabbitMQ环境
Spring boot+RabbitMQ环境 消息队列在目前分布式系统下具备非常重要的地位,如下的场景是比较适合消息队列的: 跨系统的调用,异步性质的调用最佳. 高并发问题,利用队列串行特点. 订阅模 ...
- Spring Boot 多环境如何配置
Spring Boot 开发环境.测试环境.预生产环境.生产环境多环境配置 通常一个公司的应程序可能在开发环境(dev).测试环境(test).生产环境(prod)中运行.那么是不是需要拷贝不同的安装 ...
- spring boot 开发环境搭建(Eclipse)
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- 从头开始搭建一个Spring boot+RabbitMQ环境
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...
- kotlin web开发教程【一】从零搭建kotlin与spring boot开发环境
IDEA中文输入法的智能提示框不会跟随光标的问题 我用的开发工具是IDEA 这个版本的IDEA有一个问题: 就是中文输入法的智能提示框不会跟随光标 解决这个问题的办法很简单,只有在安装目录下把JRE文 ...
- Spring boot 应用打包部署
1.Spring Boot内置web spring Boot 其默认是集成web容器的,启动方式由像普通Java程序一样,main函数入口启动.其内置Tomcat容器或Jetty容器,具体由配置来决定 ...
- Spring boot+ logback环境下,日志存放路径未定义的问题
日志路径未定义 环境:Spring boot + logback 配置文件: <configuration> <springProfile name="dev"& ...
随机推荐
- Linux下汇编语言学习笔记20 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- C++ fill 和memset
以下内容来自www.cplusplus.com--------------------------------------------------- FILL: template <class ...
- wget: unable to resolve host address “mirrors.163.com” 的解决办法
wget:无法解析主机地址.这就能看出是DNS解析的问题. 解决办法: 登入root(VPS). 进入/etc/resolv.conf. 修改内容为下nameserver 8.8.8.8 #googl ...
- Systemtap工具查看系统资源使用
http://www.xbwolf.com/507 http://blog.csdn.net/kafeiflynn/article/details/6429976 安装步骤yum install sy ...
- mysql-performance-schema
http://www.fromdual.com/mysql-performance-schema-hints http://www.cnblogs.com/cchust/
- C# 图片识别(支持21种语言)转
来自:http://www.cnblogs.com/stone_w/archive/2011/10/08/2202397.html 图片识别的技术到几天已经很成熟了,只是相关的资料很少,为了方便在此汇 ...
- [52ABP系列] - 001、SPA免费项目模版搭建教程
前言 这个项目是基于 ABP ASPNetCore 免费版,整合 NG-Alian 和 NG-Zorro 的项目,所以比较适合熟悉 ABP 和 Angular2+ 的开发人员, 如果你是新手,学习的话 ...
- 链表倒置,这个还是考验仔细程度,第一遍还没做对 —— 剑指Offer
https://www.nowcoder.net/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage= ...
- nodejs v8引擎c++编译版本号升级教程
原GCC版本号:4.4.7. 目标:升级GCC到4.8.2.以支持C++11. yum install gcc-c++ 获取GCC 4.8.2包:wget http://gcc.skazkaforyo ...
- 使用shell分页读取600万+的MySQL数据脚本
shell-mysql 脚本背景 因为要在Linux上.远程读取mysql的表的数据,然后做一定清洗后.把数据上传至Hadoop集群中,使用Java写吧,感觉太麻烦了.得在Win上开发好,还得打成ja ...