assembly打包

1 springboot项目 -> 子项目assembly

assembly子项目是微服务中的子项目,专门用来打包的

1.1 springboot项目 -> 子项目assembly -> pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><!-- 父级项目 --><parent><groupId>sac-plugin-platform</groupId> <!-- 父级项目--><artifactId>com.cenmingzhong.test</artifactId><version>1.5.7.RELEASE</version></parent><!-- pom模型版本 --><modelVersion>4.0.0</modelVersion><artifactId>assembly</artifactId><!-- 项目名 --><!-- 属性设置 --><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties><!-- 编译 --><build><!-- 插件 --><plugins><!-- maven插件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>2.4.1</version><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>single</goal></goals><configuration><finalName>${parent.artifactId}</finalName><descriptors><descriptor>src/main/resources/assembley/assembly.xml</descriptor></descriptors></configuration></execution></executions></plugin></plugins></build>
</project>

1.2 springboot项目 -> 子项目assembly -> assembly.xml文件

该配置作为maven-assembly-plugin插件的打包配置文件

<?xml version='1.0' encoding='UTF-8'?>
<assembly><id>${parent.version}</id><baseDirectory>${project.artifactId}</baseDirectory><includeBaseDirectory>true</includeBaseDirectory><formats><format>tar.gz</format> <!-- 打包的文件格式:zip、tar、tar.gz、tar.bz2、jar、war等--></formats><moduleSets><moduleSet><includes><!-- 包含的子项目--><include>com.cenmingzhong.test:boot</include> </includes></moduleSet></moduleSets><!-- 用来设置一组文件在打包时的属性--><fileSets><!-- 设置jar--><fileSet>            <directory>../boot/target</directory> <!-- 源目录的路径--><outputDirectory>target</outputDirectory>  <!-- 生成目录的路径--> <!-- 设定包含哪些文件,支持通配符--><includes><include>boot.jar</include></includes></fileSet><!-- 设置lib--><fileSet><directory>../boot/target/lib</directory> <!-- 源目录的路径--><outputDirectory>lib</outputDirectory>  <!-- 生成目录的路径--> <!-- 设定包含哪些文件,支持通配符--><includes><include>*.jar</include>    </includes></fileSet><!-- 设置bin--><fileSet><directory>src/main/resources</directory> <!-- 源目录的路径--><outputDirectory>/</outputDirectory>  <!-- 生成目录的路径--> <!-- 设定包含哪些文件,支持通配符--><includes><include>/bin/*.sh</include></includes><!-- 设定排除哪些文件,支持通配符--><excludes><exclude>joke.sh</exclude></excludes><fileMode>0755</fileMode>  <!-- 指定该目录下的文件属性,采用Unix八进制描述法,默认值是0644,设置文件权限--></fileSet><!-- 设置conf--><fileSet><directory>../boot/src/main/resource</directory> <!-- 源目录的路径--><outputDirectory>conf</outputDirectory>  <!-- 生成目录的路径--> <!-- 设定包含哪些文件,支持通配符--><includes><include>boot.yml</include> </includes></fileSet>    </fileSets>
</assembly>

2 springboot项目 -> 子项目boot

boot子项目是其中一个微服务

2.1 springboot项目 -> 子项目boot -> pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><!-- 父级项目 --><parent><groupId>sac-plugin-platform</groupId> <!-- 父级项目--><artifactId>com.cenmingzhong.test</artifactId><version>1.5.7.RELEASE</version></parent><!-- pom模型版本 --><modelVersion>4.0.0</modelVersion><artifactId>boot</artifactId><!-- 项目名 --><!-- 属性设置 --><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties><!-- 依赖关系 --><dependencies><!-- 测试 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- springmvc --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- jpa(持久层) --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><!-- mysql(数据库) --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency></dependencies><!-- 编译 --><build><finalName>${project.artifactId}</finalName><!-- 插件 --><plugins><!-- maven插件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><version>3.2.0</version><configuration><archive><manifest><addClasspath>true</addClasspath><classpathPrefix>../lib</classpathPrefix><!-- 此处修改为应用入口类全路径 --><mainClass>com.cenmingzhong.test.boot.BootBootStrap</mainClass></manifest></archive></configuration></plugin><plugin><!-- 这个插件用来把依赖的jar包复制出来放在编译后的target/lib目录,并且在打包的时候排除内部依赖 --><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><version>3.0.2</version><executions><execution><id>copy-dependencies</id><phase>prepare-package</phase><goals><goal>copy-dependencies</goal></goals><configuration><outputDirectory>target/lib</outputDirectory><overWriteReleases>false</overWriteReleases> <!-- 释放检查 overWriteReleases 值(默认值=假)。如果为真,则将强制覆盖--><overWriteSnapshots>false</overWriteSnapshots><!-- 快照检查 overWriteSnapshots 值(默认值=假)。如果为真,则将强制覆盖--><overWriteIfNewer>true</overWriteIfNewer><!-- 如果上面的任何一个都不设置为true,则默认为 overWriteIfNewer 值(默认值=真)。如果该值为真,则仅当源比目标更新(或目标中不存在)时,才会复制该插件--></configuration></execution></executions></plugin><plgin><!-- 这个插件用来生成smart-doc文档 --><groupId>com.github.shalousun</groupId><artifactId>smart-doc-maven-plugin</artifactId><version>${smart-doc-version}</version> <!-- 版本号定义在父级pom.xml中--><configuration><!-- 指定生成文档的使用的配置文件,配置文件放在自己的子项目中--><configFile>./src/main/resources/smart-doc.json</configFile><!-- 指定项目名称--><projectName>主程序</projectName><excludes><!-- 格式为:groupId:artifactId--><exclude>com.alibaba:fastjson</exclude></excludes><includes><!-- 格式为:groupId:artifactId--><include>com.alibaba.fastjson</include></includes></configuration><executions><execution><phase>compile</phase><!-- 如果不需要在执行编译时启动smart-doc,则将phase注释掉--><goals><goal>html</goal><!-- smart-doc提供了html、openapi、markdown等goal,可按需配置--></goals></execution></excutions></plgin></plugins></build>
</project>

2.2springboot项目 -> 子项目boot -> smart-doc.json文件

这个文件用来配置smart-doc插件文档输出内容的

{"projectName": "boot","isStrict": false,"outPath": "D://smart-doc" #文档输出路径"apiConstants":[{"constantsClassName": "com.cenmingzhong.test.boot.Api" #项目中的接口类
}]
}

3 springboot项目 -> 父项目parent

3.1springboot项目 -> 父项目parent->pom.xml文件

这个文件是微服务的父级项目的pom.xml配置文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><groupId>sac-plugin-platform</groupId><artifactId>com.cenmingzhong.test</artifactId><!-- 项目名 --><version>1.5.7.RELEASE</version><!-- pom模型版本 --><modelVersion>4.0.0</modelVersion><!-- 子项目 -->     <modules><module>boot</module></modules><!-- 打包方式,微服务父级项目用pom, 指定packing打包类型,maven插件可以自动加载并继承父pom相关配置 -->  <packaging>pom</packaging><!-- 属性设置 --><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><smart-doc-version>2.1.9</smart-doc-version> <!-- 配置子项目用到的依赖的版本,如果子项目没有指定版本,则使用父级项目的版本 --></properties><!-- 依赖关系 --><dependencies><!-- 测试 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- springmvc --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- jpa(持久层) --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><!-- mysql(数据库) --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency></dependencies><!-- 编译 --><build><finalName>${project.artifactId}</finalName><!-- 插件 --><plugins><!-- maven插件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>2.3.1</version><configuration><source>1.8</source> <!-- maven-compiler-plugin父pom中的默认配置如果不符合现有项目要求则要重新设置来覆盖,建议重新配置--><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><!-- maven-surefire-plugin是maven里执行测试用例的插件,不显示配置就会用默认配置。这个插件的surefire:test命令会默认绑定maven执行的test阶段 --><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.17</version><configuration><skipTests>true</skipTests>  <!-- 跳过测试 --></configuration></plugin></plugins><!-- 资源目录 可以将除了resources目录下面的文件打进包里,例如写在src/main/java里面的xml文件,可以打进resources里面,该配置实际上是作用在maven-resources-plugin插件 -->    <resources><resource><directory>src/main/java</directory><!-- 设定主资源目录  --> <!-- maven default生命周期,process-resources阶段执行maven-resources-plugin插件的resources目标处理主资源目下的资源文件时,只处理如下配置中包含的资源类型 --> <includes> <include>**/*.dic</include> <!-- **/*这样的写法,是为了保证各级子目录下的资源文件被打包--><include>**/*.xml</include><include>**/*.yml</include><include>**/*.sql</include><include>**/*.key</include></includes><excludes><exclude>**/*.joke</exclude> <!--过滤joke文件--></excludes></resource><resource><directory>src/main/resources</directory></resource></resources></build>
</project>

assembly打包相关推荐

  1. java assembly 打包_maven 使用assembly 进行打包的方法

    1. pom 中添加assembly 插件 要使用assembly 进项编译打包, 首先主要在pom 中的build中添加插件信息, 具体如图下所示: ${project.artifactId} sr ...

  2. 使用 assembly 打包报错

    使用 assembly 打包报错 The following patterns were never triggered in this artifact inclusion filter: o '* ...

  3. maven assembly打包zip报错 You must set at least one file.

    文章目录 maven assembly打包Error creating assembly archive pack: You must set at least one file. maven ass ...

  4. 使用assembly打包

    1.在pom增加插件 <build><plugins><!--使用maven-jar-plugin将指定包目录打成单独的jar包 --><plugin> ...

  5. Maven assembly打包文件被覆盖问题

    Maven的assembly插件使用: 最近在做一个小工程,利用java启动运行. 为了简单方便使用运行,利用maven的assembly将需要使用的jar都打包到一个jar中.这样无论拷贝到哪里,只 ...

  6. springboot项目assembly打包配置

    项目的目录结构如图: 下面是主要的配置文件内容: assembly.xml <?xml version="1.0" encoding="UTF-8"?&g ...

  7. idea 中maven assembly 打包项目

    使用assembly插件来打包项目: 1>在pom.xml中配置assembly插件 <properties><project.build.sourceEncoding> ...

  8. maven assembly打包插件详解

    定义 来自官方的定义: Maven Assembly Plugin relies on the provided assembly descriptors to dictate its executi ...

  9. java assembly 打包_使用Maven的assembly插件实现自定义打包

    一.背景 最近我们项目越来越多了,然后我就在想如何才能把基础服务的打包方式统一起来,并且可以实现按照我们的要求来生成,通过研究,我们通过使用maven的assembly插件完美的实现了该需求,爽爆了有 ...

最新文章

  1. [Notice]博客地址转移 vitostack.com
  2. 【JZOJ5064】【GDOI2017第二轮模拟day2】友好城市 Kosarajo算法+bitset+ST表+分块
  3. Swift函数_默认参数
  4. mysql有那么多存储引擎_MySQL的多存储引擎架构
  5. 光脚丫学LINQ(025):如何验证DBML和外部映射文件
  6. jmeter mysql 连接复用_JMeter 连接MySQL
  7. 如何快速理解递归——看这个就可以了
  8. 《FPGA入门教程》看书随笔——RTL设计
  9. BootstrapVue UI组件
  10. mysql 创建查询 删除_MYSQL数据库查询删除创建企业基本知识
  11. 巨坑!这公司的行为,挺适合清明节!
  12. windows10查看本机IP脚本
  13. NES模拟器[H_NES]
  14. 计算机数学的建议,2021考研计算机数学备考建议
  15. linux服务器安全与配置,Linux系统服务器安装后的安全配置
  16. 使用Retinanet训练自己的数据集
  17. 轻松在线差异基因/物种分析和可视化
  18. 计算机电源大小,电源功率到底选多大?老司机告诉你电源功率怎么选?
  19. 嵌入式截屏工具-gsnap移植 arm平台
  20. 亚信科技java面试题及答案.doc

热门文章

  1. 什么运动耳机防水防汗好用、防水防汗最好的运动蓝牙耳机
  2. 什么是RAID及创建RAID的方法
  3. GitLab修改群组信息
  4. VSCode 插件(分类查找)
  5. 专注协同和GRC,慧点20载践行中国软件助力中国企业走向世界
  6. 高效数字化办公体验 企业级扫描捕获解决方案解析
  7. 如何确定 Winsock2 是否损坏并从损坏中恢复
  8. Spring循环依赖问题解决
  9. HDU 4749 Parade Show(暴力水果)
  10. 基于视频编码器的直播参数设置的图文教程