Go 语言系统编程与云原生开发实战(第20篇)

核心内容摘要

深度测评 9个降AIGC软件:自考降AI率必备工具全对比
VoiceFixer高级技巧:自定义声码器函数,打造专属语音修复方案

【计算机毕业设计案例】基于springboot心理测试评估小程序基于springboot+小程序的智慧心理健康自助平台小程序的设计与实现(程序+文档+讲解+定制)

打包是一个比较头疼的事情默认maven打包的结果只包含项目本身的代码如果要执行代码还得带上依赖。

如果希望将所有依赖放到指定的文件夹下再在目录下写入shell脚本等之类的事情。

maven-shade-plugin插件不能满足需求而maven-assembly-plugin插件能够帮我们合理地归档文件。

简单的使用assembly提供了几种默认的打包方式使用 descriptorRefs descriptorRef 有 bin, jar-with-dependencies, src, project。

【不建议使用】代码语言javascriptAI代码解释plugins plugin !-- NOTE: We dont need a groupId specification because the group is org.apache.maven.plugins ...which is assumed by default. -- artifactIdmaven-assembly-plugin/artifactId version

3.

0/version configuration descriptorRefs descriptorRefjar-with-dependencies/descriptorRef /descriptorRefs /configuration /plugindescriptor使用原理assembly允许用户自定义归档文件格式位置结构等信息。

允许配置并执行多个自定义配置。

所以每一个配置都需要一个唯一id来做区分。

归档格式可以有tar.gz,dir,zip,war等等允许同时归档出多种格式文件。

对于打的jar包可以指定输出目录。

对于一组特定的文件可以指定存放的文件夹。

如果有单独需要存放的文件也可以单独处理。

assembly配置assembly配置分为两部分一部分是assembly的配置文件一部分是在pom.xml中的配置。

assembly配置文件首先我们通过以下配置文件了解一下配置文件是怎么工作的。

代码语言javascriptAI代码解释assembly xmlnshttp://maven.apache.org/ASSEMBLY/

2.

0 xmlns:xsihttp://www.w

org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/ASSEMBLY/

2.

0 http://maven.apache.org/xsd/assembly-

2.

0.

xsd http://maven.apache.org/ASSEMBLY/

2.

0 !--唯一ID-- idassembly_test/id !--打包格式允许同时有多个-- formats formattar.gz/format formatdir/format formatzip/format /formats !--依赖jar包以及项目打包文件存储文件-- dependencySets dependencySet !--存储在projectName-assembly-version/lib下-- outputDirectorylib/outputDirectory /dependencySet /dependencySets fileSets fileSet !--目录路径如果不在这里指定而在include中指定那么其文件夹的也会被带进去-- directorysrc/main/bin//directory includes !--要哪些文件-- include*.*/include /includes excludes !--不要哪些文件-- exclude*.no_need/exclude /excludes !--文件的权限-- fileMode0755/fileMode !--输出目录 存储在projectName-assembly-version/bin下-- outputDirectorybin/outputDirectory directoryMode0755/directoryMode /fileSet /fileSets files !--针对单个文件-- file !--源文件地址相对于项目地址-- sourcepom.xml/source !--输出目录为projectName-assembly-version/-- outputDirectory./outputDirectory !--文件的权限-- fileMode0755/fileMode !--重命名为-- destNamepom.xml/destName /file /files /assemblypom中的配置assembly插件在pom中配置较为简单但需要配置maven自带的插件实现main方法添加和classpath依赖。

假设上边的assembly配置文件在src/main/assembly/assembly.xmlpom配置内容为代码语言javascriptAI代码解释build plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-jar-plugin/artifactId version

2.

1/version configuration archive manifest !--运行jar包时运行的主类要求类全名-- mainClasscom.gavinzh.learn.assembly.Main/mainClass !-- 是否指定项目classpath下的依赖 -- addClasspathtrue/addClasspath !-- 指定依赖的时候声明前缀 -- !--classpathPrefix.//classpathPrefix-- /manifest /archive /configuration /plugin plugin !-- NOTE: We dont need a groupId specification because the group is org.apache.maven.plugins ...which is assumed by default. -- artifactIdmaven-assembly-plugin/artifactId version

3.

0/version configuration descriptors descriptorsrc/main/assembly/assembly.xml/descriptor /descriptors /configuration executions execution idassembly_test/id phasepackage/phase goals goalsingle/goal /goals /execution /executions /plugin /plugins /build参考Apache Maven Assembly Pluginhttps://www.jianshu.com/p/14bcb17b99e0

榴莲视频色-榴莲视频色应用

百度百家号客服电话人工服务

123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123