通过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 ...
随机推荐
- sql优化使用技巧
1.LIMIT 语句分页查询是最常用的场景之一,但也通常也是最容易出问题的地方.比如对于下面简单的语句,一般 DBA 想到的办法是在 type, name, create_time 字段上加组合索引. ...
- JDK源码中,都有哪些NB的设计模式?
转载:https://mp.weixin.qq.com/s/h88UxB9F2MkTbHqck3KQiQ 一.结构性模式: 1.适配器模式: 常用于将一个新接口适配旧接口 肥朝小声逼逼:在我们业务代码 ...
- hadoop单机模式安装流程
这里的安装是在Linux系统上安装的 参考博客 : https://blog.csdn.net/cafebar123/article/details/73500014 https://blog.csd ...
- CentOS安装Python模块cx_Oracle
在线安装 $ wget https://bootstrap.pypa.io/get-pip.py$ python get-pip.py$ pip -V #查看pip版本 或者将网页中的代码复制到get ...
- DatakeyNames和datakey
DataKey 类用于表示数据绑定控件中某个记录的主键.记录的主键可以由数据源中的一个或多个字段组成.尽管 DataKey 类不是集合,但它可以存储多个键字段值.当调用 DataKey 类的某个构造函 ...
- python大法好——多线程
Python 多线程 多线程类似于同时执行多个不同程序,多线程运行有如下优点: 使用线程可以把占据长时间的程序中的任务放到后台去处理. 用户界面可以更加吸引人,这样比如用户点击了一个按钮去触发某些事件 ...
- dojo里添加目录树
其实循环生成目录树这个方法不仅仅局限于在使用dojo的情况下,只要明白了其中的原理,在任何一种语言下都能动态循环生成. 1. 数据结构 在这里先说明一下数据结构,我这里循环生成目录树的数据结构是像这样 ...
- React 获取服务器API接口数据:axios、fetchJsonp
使用axios.fetchJsonp获取服务器的接口数据.其中fetchJsonp是跨域访问 一.使用axios 1.安装axios模块 npm install --save axios 2.引用模块 ...
- elasticsearch增删查改
创建结构化索引 put http://127.0.0.1:9200/person{ "settings" : { "number_of_shards": 3, ...
- centos下删除MYSQL 和重新安装MYSQL
centos下彻底删除MYSQL 和重新安装MYSQL 因centos系统自带的mysql版本比较低5.1,所以想卸载重新安装较新版本,下面是过程 1 删除Mysql yum remove mysql ...