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环境可执行脚本直接安装成系统服务的更多相关文章

  1. maven将自己的springboot项目打包成jar包后,作为工具包引入其他项目,找不到jar中的类

    将springboot项目打包成jar包,作为工具包导入项目后,找不到jar中的类. 原因是:springboot项目使用了自动的打包插件. 原先的插件配置: <build> <pl ...

  2. 用gradle把springboot项目打包成jar

    ``` 用gradle把springboot项目打包成jar ```### build.gradle 中添加 buildscript { repositories { mavenLocal() mav ...

  3. SpringBoot项目打包成jar后,启动脚本

    将springboot项目打包成jar后,上传至服务器,每次都需要手敲命令,重新部署项目,可将这些命令写入脚本中,直接运行. 启动脚本(start.sh): CUR_PATH=$(cd "$ ...

  4. Spring Boot项目使用maven-assembly-plugin根据不同环境打包成tar.gz或者zip

    spring-boot-assembly 在spring boot项目中使用maven profiles和maven assembly插件根据不同环境打包成tar.gz或者zip 将spring bo ...

  5. springboot项目打包成jar/war包

    springboot项目打包过程中包含第三方jar 开发IDE是IntelliJ IDEA,数据库是mysql,内置服务器tomcat. 打包步骤: 1. 确定项目调试运行没问题 2. 将第三方jar ...

  6. Springboot项目打包成jar运行2种方式

    最近公司有个项目需要移植到SpringBoot框架上,项目里面又有许多第三方jar包,在linux服务器上最方便的就是用jar的方式来运行SpringBoot项目了,因此我研究了2种打jar包的方式, ...

  7. IDEA中springboot项目打包成jar

      springboot的打包方式有很多种.有打成war的,有打成jar的,也有直接提交到github,通过jekins进行打包部署的.这里主要介绍如何打成jar进行部署.不推荐用war,因为spri ...

  8. springboot项目打包成jar包在Linux服务器默认80端口运行

    springboot项目端口设置 在application.properties文件 server.port=80 在application.yml文件 server: port: 80 然后在ide ...

  9. 在IDEA中将SpringBoot项目打包成jar包的方法

    SpringBoot项目无需依赖tomcat容器(内含)就可以发布,现在将打包步骤记录一下: 1. 打包前确认项目可以正常运行,打开Project Structure 快捷键 Ctrl+Shift+A ...

随机推荐

  1. Postman A请求的返回值作为B请求的入参( 之‘’token‘’ ,用代码设置全局变量)

    问题: 登陆接口获取token,其他接口访问时需携带token 方案: 在登陆接口访问后设置Postman的全局变量(Globals),例如设置环境变量名:token2,值(实时的不用自己手动设置的) ...

  2. C#异步方法

      Task MainTask;   MainTask = Task.Factory.StartNew(() =>             { //耗时的异步逻辑 });

  3. 002.[python学习]python编码规范pep8学习——PEP8第一部分代码布局

    关于PEP8的详细说明可以参考官方原文:http://legacy.python.org/dev/peps/pep-0008/ 我参考官方文档及其他文章,摘出相关内容而得此文章,具体参考其他文章见文中 ...

  4. 13. nginx,lvs之一

    摘要: 1.详细描述常见nginx常用模块和模块的使用示例 2.简述Linux集群类型.系统扩展方式及调度方法 3.简述lvs四种集群有点及使用场景 4.描述LVS-NAT.LVS-DR的工作原理并实 ...

  5. 1. [Vue warn]: Missing required prop: "value"

    意思是说数据没有绑定,页面缺少value值.应该v-model进行数据绑定.

  6. python目录结构

    import sys,os #__file__取得当前文件名,pycharm会自动加上完整路径 #os.path.dirname取得上一级目录 #os.path.abspath取得绝对路径 BASE_ ...

  7. Hadoop Mapreduce运行流程

    Mapreduce的运算过程为两个阶段: 第一个阶段的map task相互独立,完全并行: 第二个阶段的reduce task也是相互独立,但依赖于上一阶段所有map task并发实例的输出: 这些t ...

  8. EMF32名词解释

    (EFM32)32位节能微控制器(Energy Friendly Microcontroller 32-bit) (Gecko)壁虎 (Starter Kit)入门套件 (STK)入门套件 (Debu ...

  9. centos7 根分区扩容

    系统安装时候使用的默认分区,根分区只分了50G,使用的是LVM 想把home分区分出来660G给根分区 先查了点资料开搞 由于xfs分区只支持增大,不支持缩小,所以home目前是xfs格式无法进行缩小 ...

  10. MySQL 登陆

    #==========================登陆mysql ============================================ # 登陆用户名:-u,登陆IP: -h, ...