spring-boot分环境打包为tar包
1.pom配置
- <!-- 多环境打包 start -->
- <profiles>
- <!-- 开发环境配置 -->
- <profile>
- <id>dev</id>
- <properties>
- <profiles.active>dev</profiles.active>
- </properties>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- </profile>
- <!-- 测试环境配置 -->
- <profile>
- <id>test</id>
- <properties>
- <profiles.active>test</profiles.active>
- </properties>
- </profile>
- <!-- 正式环境 -->
- <profile>
- <id>online</id>
- <properties>
- <profiles.active>online</profiles.active>
- </properties>
- </profile>
- </profiles>
- <!-- 多环境打包 end -->
- <build>
- <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>
- <includes>
- <include>*.xml</include>
- <include>*.properties</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- <resource>
- <directory>src/main/resources/conf/${profiles.active}</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>3.0.0</version>
- <configuration>
- <!-- 生成的tar.gz文件的名字,如果没有设置就默认用pom文件里的artifactId+version-->
- <finalName>${project.artifactId}</finalName>
- <!-- 属性控制是否在生成的打包文件的文件名中包含assembly id -->
- <appendAssemblyId>false</appendAssemblyId>
- <descriptors>
- <!--描述文件路径-->
- <descriptor>src/main/assembly/assembly.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <!-- 绑定到package生命周期阶段上 -->
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
2.assembly.xml文件
- <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>dist</id>
- <formats>
- <format>tar.gz</format>
- </formats>
- <includeBaseDirectory>true</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>src/main/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <directoryMode>0777</directoryMode>
- <includes>
- <include>**/*</include>
- </includes>
- <fileMode>0777</fileMode>
- <lineEnding>unix</lineEnding>
- </fileSet>
- <fileSet>
- <directory>target/classes</directory>
- <outputDirectory>conf</outputDirectory>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- <excludes>
- <exclude>**/*.class</exclude>
- </excludes>
- </fileSet>
- </fileSets>
- <dependencySets>
- <!-- copy all third party jars to lib folder. -->
- <dependencySet>
- <outputDirectory>lib</outputDirectory>
- <excludes>
- <exclude>com.dangdang:*</exclude>
- </excludes>
- </dependencySet>
- <!-- copy all dangdang jars to app folder. -->
- <dependencySet>
- <outputDirectory>app</outputDirectory>
- <includes>
- <include>com.dangdang:*</include>
- </includes>
- <fileMode>0644</fileMode>
- </dependencySet>
- </dependencySets>
- </assembly>
3.启动脚本
nohup java -classpath lib路径:conf路径:app路径:. 启动类 > /dev/null 2>&1 &
命令如上,具体可参考我上传的文件
spring-boot分环境打包为tar包的更多相关文章
- spring-boot分环境打包为war包
1.启动类修改 @EnableSwagger2 @SpringBootApplication public class CustWebAcApplication extends SpringBootS ...
- spring-boot分环境打包为jar包
1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...
- Spring boot 分环境部署
一.如果配置文件为:application.properties时 1.application.properties用于填些公共文件 以下为不同环境的配置文件需要单独配置 application-de ...
- Spring Boot项目使用maven-assembly-plugin根据不同环境打包成tar.gz或者zip
spring-boot-assembly 在spring boot项目中使用maven profiles和maven assembly插件根据不同环境打包成tar.gz或者zip 将spring bo ...
- 将 Spring boot 项目打成可执行Jar包,及相关注意事项(main-class、缺少 xsd、重复打包依赖)
最近在看 spring boot 的东西,觉得很方便,很好用.对于一个简单的REST服务,都不要自己部署Tomcat了,直接在 IDE 里 run 一个包含 main 函数的主类就可以了. 但是,转念 ...
- Spring boot(4)-应用打包部署
1.Spring Boot内置web spring Boot 其默认是集成web容器的,启动方式由像普通Java程序一样,main函数入口启动.其内置Tomcat容器或Jetty容器,具体由配置来决定 ...
- Spring Boot使用Maven打包替换资源文件占位符
在Spring Boot开发中,通过Maven构建项目依赖是一件比较舒心的事,可以为我们省去处理冲突等大部分问题,将更多的精力用于业务功能上.近期在项目中,由于项目集成了其他外部系统资源文件,需要根据 ...
- Spring Boot(十二):spring boot如何测试打包部署
Spring Boot(十二):spring boot如何测试打包部署 一.开发阶段 1,单元测试 在开发阶段的时候最重要的是单元测试了,springboot对单元测试的支持已经很完善了. (1)在p ...
- springboot分环境打包(maven动态选择环境)
分环境打包核心点:spring.profiles.active pom.xml中添加: <profiles> <profile> <id>dev</id> ...
随机推荐
- range循环
for i in range(10): #特殊写法,从0开始,步长为1,最大值小于10 print("loop",i) print("=========") f ...
- P1558 色板游戏
P1558 色板游戏 题目背景 阿宝上学了,今天老师拿来了一块很长的涂色板. 题目描述 色板长度为L,L是一个正整数,所以我们可以均匀地将它划分成L块1厘米长的小方格.并从左到右标记为1, 2, .. ...
- Pycharm远程连接服务器,并在本地调试服务器代码
问题描述 其实有很多教程了,我只是想记录一下设置得记录,这样就能充分利用阿里云服务器为我跑代码了... 步骤一:配置deployment 步骤二:选择远程python解释器 步骤三:将本地文件上传至远 ...
- Java基础-IO流对象之File类
Java基础-IO流对象之File类 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.IO技术概述 回想之前写过的程序,数据都是在内存中,一旦程序运行结束,这些数据都没有了,等下 ...
- vue相关安装命令
安装cnpm npm install cnpm -g --registry=https://registry.npm.taobao.org
- Mongodb 笔记04 特殊索引和集合、聚合、应用程序设计
特殊索引和集合 1. 固定集合:固定集合需要事先创建好看,而且它的大小是固定的.当固定集合被占满时,如果再插入新文档,固定集合会自动将最老的文档从集合中删除. 2. 创建固定集合:db.createC ...
- java字节码文件 helloworld
Java代码 \\A.java public class A{} 1 2 1 2 javac A.java \\得到 A.class javap -v A.class 下面是javap工具帮我们生成的 ...
- 线程中wait/notify/notifyAll的用法
前言 多线程时,最关注的就是线程同步,线程间的同步一般用锁来实现,常见的锁就是synchronized和lock.用了synchronized,就不得不提到wait/notify/notifyAll. ...
- POJ 1741 Tree 求树上路径小于k的点对个数)
POJ 174 ...
- [整理]标准C中的"布尔"类型
C语言提供的基本数据类型:char , int ,float, double. 为什么没有其他语言中常见bool布尔数据类型呢? 1.在标准C语言(ANSI C)中并没有bool数据类型 标准C中,表 ...