1.pom配置

  1. <!-- 多环境打包 start -->
  2. <profiles>
  3. <!-- 开发环境配置 -->
  4. <profile>
  5. <id>dev</id>
  6. <properties>
  7. <profiles.active>dev</profiles.active>
  8. </properties>
  9. <activation>
  10. <activeByDefault>true</activeByDefault>
  11. </activation>
  12. </profile>
  13. <!-- 测试环境配置 -->
  14. <profile>
  15. <id>test</id>
  16. <properties>
  17. <profiles.active>test</profiles.active>
  18. </properties>
  19. </profile>
  20. <!-- 正式环境 -->
  21. <profile>
  22. <id>online</id>
  23. <properties>
  24. <profiles.active>online</profiles.active>
  25. </properties>
  26. </profile>
  27. </profiles>
  28. <!-- 多环境打包 end -->
  29.  
  30. <build>
  31. <resources>
  32. <resource>
  33. <directory>src/main/java</directory>
  34. <includes>
  35. <include>**/*.class</include>
  36. <include>**/*.xml</include>
  37. <include>**/*.properties</include>
  38. </includes>
  39. </resource>
  40. <resource>
  41. <directory>src/main/resources</directory>
  42. <includes>
  43. <include>*.xml</include>
  44. <include>*.properties</include>
  45. </includes>
  46. <filtering>true</filtering>
  47. </resource>
  48. <resource>
  49. <directory>src/main/resources/conf/${profiles.active}</directory>
  50. </resource>
  51. </resources>
  52. <plugins>
  53. <plugin>
  54. <groupId>org.apache.maven.plugins</groupId>
  55. <artifactId>maven-assembly-plugin</artifactId>
  56. <version>3.0.0</version>
  57. <configuration>
  58. <!-- 生成的tar.gz文件的名字,如果没有设置就默认用pom文件里的artifactId+version-->
  59. <finalName>${project.artifactId}</finalName>
  60. <!-- 属性控制是否在生成的打包文件的文件名中包含assembly id -->
  61. <appendAssemblyId>false</appendAssemblyId>
  62. <descriptors>
  63. <!--描述文件路径-->
  64. <descriptor>src/main/assembly/assembly.xml</descriptor>
  65. </descriptors>
  66. </configuration>
  67. <executions>
  68. <execution>
  69. <id>make-assembly</id>
  70. <!-- 绑定到package生命周期阶段上 -->
  71. <phase>package</phase>
  72. <goals>
  73. <goal>single</goal>
  74. </goals>
  75. </execution>
  76. </executions>
  77. </plugin>
  78. </plugins>
  79. </build>

2.assembly.xml文件

  1. <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  4. <id>dist</id>
  5. <formats>
  6. <format>tar.gz</format>
  7. </formats>
  8. <includeBaseDirectory>true</includeBaseDirectory>
  9. <fileSets>
  10. <fileSet>
  11. <directory>src/main/bin</directory>
  12. <outputDirectory>bin</outputDirectory>
  13. <directoryMode>0777</directoryMode>
  14. <includes>
  15. <include>**/*</include>
  16. </includes>
  17. <fileMode>0777</fileMode>
  18. <lineEnding>unix</lineEnding>
  19. </fileSet>
  20. <fileSet>
  21. <directory>target/classes</directory>
  22. <outputDirectory>conf</outputDirectory>
  23. <includes>
  24. <include>**/*.properties</include>
  25. <include>**/*.xml</include>
  26. </includes>
  27. <excludes>
  28. <exclude>**/*.class</exclude>
  29. </excludes>
  30. </fileSet>
  31. </fileSets>
  32. <dependencySets>
  33. <!-- copy all third party jars to lib folder. -->
  34. <dependencySet>
  35. <outputDirectory>lib</outputDirectory>
  36. <excludes>
  37. <exclude>com.dangdang:*</exclude>
  38. </excludes>
  39. </dependencySet>
  40.  
  41. <!-- copy all dangdang jars to app folder. -->
  42. <dependencySet>
  43. <outputDirectory>app</outputDirectory>
  44. <includes>
  45. <include>com.dangdang:*</include>
  46. </includes>
  47. <fileMode>0644</fileMode>
  48. </dependencySet>
  49.  
  50. </dependencySets>
  51. </assembly>

3.启动脚本

nohup java -classpath lib路径:conf路径:app路径:. 启动类 > /dev/null 2>&1 &
命令如上,具体可参考我上传的文件

spring-boot分环境打包为tar包的更多相关文章

  1. spring-boot分环境打包为war包

    1.启动类修改 @EnableSwagger2 @SpringBootApplication public class CustWebAcApplication extends SpringBootS ...

  2. spring-boot分环境打包为jar包

    1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...

  3. Spring boot 分环境部署

    一.如果配置文件为:application.properties时 1.application.properties用于填些公共文件 以下为不同环境的配置文件需要单独配置 application-de ...

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

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

  5. 将 Spring boot 项目打成可执行Jar包,及相关注意事项(main-class、缺少 xsd、重复打包依赖)

    最近在看 spring boot 的东西,觉得很方便,很好用.对于一个简单的REST服务,都不要自己部署Tomcat了,直接在 IDE 里 run 一个包含 main 函数的主类就可以了. 但是,转念 ...

  6. Spring boot(4)-应用打包部署

    1.Spring Boot内置web spring Boot 其默认是集成web容器的,启动方式由像普通Java程序一样,main函数入口启动.其内置Tomcat容器或Jetty容器,具体由配置来决定 ...

  7. Spring Boot使用Maven打包替换资源文件占位符

    在Spring Boot开发中,通过Maven构建项目依赖是一件比较舒心的事,可以为我们省去处理冲突等大部分问题,将更多的精力用于业务功能上.近期在项目中,由于项目集成了其他外部系统资源文件,需要根据 ...

  8. Spring Boot(十二):spring boot如何测试打包部署

    Spring Boot(十二):spring boot如何测试打包部署 一.开发阶段 1,单元测试 在开发阶段的时候最重要的是单元测试了,springboot对单元测试的支持已经很完善了. (1)在p ...

  9. springboot分环境打包(maven动态选择环境)

    分环境打包核心点:spring.profiles.active pom.xml中添加: <profiles> <profile> <id>dev</id> ...

随机推荐

  1. range循环

    for i in range(10): #特殊写法,从0开始,步长为1,最大值小于10 print("loop",i) print("=========") f ...

  2. P1558 色板游戏

    P1558 色板游戏 题目背景 阿宝上学了,今天老师拿来了一块很长的涂色板. 题目描述 色板长度为L,L是一个正整数,所以我们可以均匀地将它划分成L块1厘米长的小方格.并从左到右标记为1, 2, .. ...

  3. Pycharm远程连接服务器,并在本地调试服务器代码

    问题描述 其实有很多教程了,我只是想记录一下设置得记录,这样就能充分利用阿里云服务器为我跑代码了... 步骤一:配置deployment 步骤二:选择远程python解释器 步骤三:将本地文件上传至远 ...

  4. Java基础-IO流对象之File类

    Java基础-IO流对象之File类 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.IO技术概述 回想之前写过的程序,数据都是在内存中,一旦程序运行结束,这些数据都没有了,等下 ...

  5. vue相关安装命令

    安装cnpm npm install cnpm -g --registry=https://registry.npm.taobao.org

  6. Mongodb 笔记04 特殊索引和集合、聚合、应用程序设计

    特殊索引和集合 1. 固定集合:固定集合需要事先创建好看,而且它的大小是固定的.当固定集合被占满时,如果再插入新文档,固定集合会自动将最老的文档从集合中删除. 2. 创建固定集合:db.createC ...

  7. java字节码文件 helloworld

    Java代码 \\A.java public class A{} 1 2 1 2 javac A.java \\得到 A.class javap -v A.class 下面是javap工具帮我们生成的 ...

  8. 线程中wait/notify/notifyAll的用法

    前言 多线程时,最关注的就是线程同步,线程间的同步一般用锁来实现,常见的锁就是synchronized和lock.用了synchronized,就不得不提到wait/notify/notifyAll. ...

  9. POJ 1741 Tree 求树上路径小于k的点对个数)

                                                                                                 POJ 174 ...

  10. [整理]标准C中的"布尔"类型

    C语言提供的基本数据类型:char , int ,float, double. 为什么没有其他语言中常见bool布尔数据类型呢? 1.在标准C语言(ANSI C)中并没有bool数据类型 标准C中,表 ...