通过maven-assembly-plugin将Springboot项目打包成tar.gz压缩包,在Linux环境可执行脚本直接安装成系统服务
1、在pom.xml中添加maven-assembly-plugin依赖,同时需将默认生成的spring-boot-maven-plugin依赖删除,否则最终打出的发行包启动会有问题
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<!-- not append assembly id in release file name -->
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/release.xml</descriptor>
</descriptors>
</configuration> <executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
2、新增release.xml
在依赖配置中的descriptor标签中定义了一个release.xml文件路径,assembly则通过该配置文件,确定打包的文件类型及其所包含的文件
<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>
<fileSet>
<directory>target</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
</assembly>
3、添加脚本文件
脚本文件的作用是为了在Linux环境下可直接运行进行服务的安装,所以需要事先将脚本编辑完成

4、打包
执行mvn clean package -Dmaven.test.skip=true命令,在target目录生成
文件,解压后,里面包含bin、conf、lib、logs这四个目录,在release.xml中可以找到对应的配置,以及存放的数据与项目文件的对应关系,都在release.xml中进行设置
5、项目链接
百度云:https://pan.baidu.com/s/1zi1zuKTeZHs8BBjYUxm1fg 密码:rkpc
通过maven-assembly-plugin将Springboot项目打包成tar.gz压缩包,在Linux环境可执行脚本直接安装成系统服务的更多相关文章
- maven将自己的springboot项目打包成jar包后,作为工具包引入其他项目,找不到jar中的类
将springboot项目打包成jar包,作为工具包导入项目后,找不到jar中的类. 原因是:springboot项目使用了自动的打包插件. 原先的插件配置: <build> <pl ...
- 用gradle把springboot项目打包成jar
``` 用gradle把springboot项目打包成jar ```### build.gradle 中添加 buildscript { repositories { mavenLocal() mav ...
- SpringBoot项目打包成jar后,启动脚本
将springboot项目打包成jar后,上传至服务器,每次都需要手敲命令,重新部署项目,可将这些命令写入脚本中,直接运行. 启动脚本(start.sh): CUR_PATH=$(cd "$ ...
- Spring Boot项目使用maven-assembly-plugin根据不同环境打包成tar.gz或者zip
spring-boot-assembly 在spring boot项目中使用maven profiles和maven assembly插件根据不同环境打包成tar.gz或者zip 将spring bo ...
- springboot项目打包成jar/war包
springboot项目打包过程中包含第三方jar 开发IDE是IntelliJ IDEA,数据库是mysql,内置服务器tomcat. 打包步骤: 1. 确定项目调试运行没问题 2. 将第三方jar ...
- Springboot项目打包成jar运行2种方式
最近公司有个项目需要移植到SpringBoot框架上,项目里面又有许多第三方jar包,在linux服务器上最方便的就是用jar的方式来运行SpringBoot项目了,因此我研究了2种打jar包的方式, ...
- IDEA中springboot项目打包成jar
springboot的打包方式有很多种.有打成war的,有打成jar的,也有直接提交到github,通过jekins进行打包部署的.这里主要介绍如何打成jar进行部署.不推荐用war,因为spri ...
- springboot项目打包成jar包在Linux服务器默认80端口运行
springboot项目端口设置 在application.properties文件 server.port=80 在application.yml文件 server: port: 80 然后在ide ...
- 在IDEA中将SpringBoot项目打包成jar包的方法
SpringBoot项目无需依赖tomcat容器(内含)就可以发布,现在将打包步骤记录一下: 1. 打包前确认项目可以正常运行,打开Project Structure 快捷键 Ctrl+Shift+A ...
随机推荐
- 解决导出CSV后在EXCEL打开纯数字前面0丢失问题
select ip ,concat('="',accountname,'"')select ip ,concat('="',accountname,'"')
- 【MySQL】5.7 复制
参考:http://www.cnblogs.com/zhoujinyi/p/5704567.html 参考:http://www.innomysql.com/article/25656.html 参考 ...
- 树——B-树
B树的定义: 1.若根结点不是终端结点,则至少有2棵子树 2.每个中间节点都包含k-1个元素和k个孩子,其中 m/2 <= k <= m 3.每一个叶子节点都包含k-1个元素,其中 m/2 ...
- 5. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
解决方案,见 https://www.jianshu.com/p/836d455663da
- JS sort() 方法
如果调用该方法时没有使用参数,将按字母顺序对数组中的元素进行排序,说得更精确点,是按照字符编码的顺序进行排序.要实现这一点,首先应把数组的元素都转换成字符串(如有必要),以便进行比较. array.s ...
- c# statusStrip控件(转)
先了解一下StatusStrip:首选StatusStrip是Form中的一个控件,同时也是一个大的控件,其中含有许多子控件,这些子控件存放在控件群中. 这样我们要使用StatusStrip时, 首先 ...
- (ZT)算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification)
https://www.cnblogs.com/leoo2sk/archive/2010/09/17/naive-bayesian-classifier.html 0.写在前面的话 我个人一直很喜欢算 ...
- nginx stream module on mt7621(newifi3 d2) with openwrt 18.06.2
因为需要使用nginx的stream模块,专门编译了一个nginx安装包,适用于openwrt 18.06.2版本,mt7621平台 顺便记录一下编译的笔记: 1.修改feeds/packages/n ...
- 2017-11-10 Fr Oct 消参
2017-11-04 Sa $ P(-3, 0) $ 在圆C $ (x-3)^2 + y^2 = 8^2 $ 内,动圆M与圆相切且过P点,求M点轨迹. 设切点 $ A(a, b) $,圆心 \(M(x ...
- Java_监听文件夹或者文件是否有变动
package org.testWatch.Watch; import java.nio.file.FileSystems; import java.nio.file.Path; import jav ...