maven java项目打包发布插件 maven-assembly-plugin
来源:互联网 发布:淘宝买家虚拟商品骗术 编辑:程序博客网 时间:2024/05/17 07:26
1.插件安装在pom.xml中配置
<plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.4.1</version> <configuration> <descriptors> <!--描述文件路径--> <descriptor>src/main/assembly/assembly.xml</descriptor> </descriptors> </configuration> <executions> <execution> <id>make-tar-gz</id> <!-- 绑定到package生命周期阶段上 --> <phase>package</phase> <goals> <!-- 绑定到package生命周期阶段上 --> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins>
其中中的内容即为assembly.xml文件的路径
2.assembly文件配置
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> <id>distribution</id> <formats> <format>tar.gz</format> </formats> <includeBaseDirectory>true</includeBaseDirectory> <fileSets> <fileSet> <directory>src/main/resources/${package.environment}</directory> <outputDirectory>conf</outputDirectory> </fileSet> <fileSet> <directory>src/main/assembly/bin</directory> <outputDirectory>bin</outputDirectory> </fileSet> <fileSet> <directory>logs</directory> <outputDirectory>logs</outputDirectory> </fileSet> <fileSet> <directory>dump_files</directory> <outputDirectory>conf</outputDirectory> </fileSet> </fileSets> <dependencySets> <dependencySet> <useProjectArtifact>true</useProjectArtifact> <outputDirectory>lib</outputDirectory> <!-- 将scope为runtime的依赖包打包到lib目录下。 --> <scope>runtime</scope> </dependencySet> </dependencySets></assembly>
其中fileSet即为项目目录directory对应最终的输出目录outputDirectory
dependencySet中为运行时依赖包的整理到lib下
3.在配置的时候会遇到一个问题
在pom.xml中配置的指定路径(systemPath)的jar包运行时无法打包到lib下。
解决方案
例如一下systemPath配置
<scope>system</scope>
<systemPath>${project.basedir}/lib/tupuApi_1.1.1.jar</systemPath>
在assembly.xml中配置即可
<fileSet>
<directory>lib</directory>
<outputDirectory>lib</outputDirectory>
</fileSet>
4.线上配置和线下配置区分pom.xml中配置
<profiles> <profile> <!-- 本地开发环境 --> <id>dev</id> <properties> <package.environment>dev</package.environment> </properties> <!-- <activation> <activeByDefault>true</activeByDefault> </activation> --> </profile> <profile> <!-- 测试环境 --> <id>test</id> <properties> <package.environment>test</package.environment> </properties> </profile> <profile> <!-- 生产环境 --> <id>product</id> <properties> <package.environment>product</package.environment> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> </profiles>
阅读全文
0 0
- maven java项目打包发布插件 maven-assembly-plugin
- maven-assembly-plugin打包插件配置
- Maven-assembly-plugin插件
- Maven的打包插件maven-assembly-plugin介绍
- maven 自定义打包插件maven-assembly-plugin不完全记录
- maven父子项目使用assembly插件打包
- Maven自定义打包插件Assembly Plugin简单使用
- Maven插件之maven-assembly-plugin
- Maven学习总结(27)——Maven自定义打包插件maven-assembly-plugin详解
- Maven Assembly打包插件介绍
- maven+assembly插件打包应用程序
- maven:maven-assembly-plugin
- 使用maven-assembly-plugin打包zip工程
- 使用maven-assembly-plugin打包dubbo接口
- Spring项目打包部署( Maven Assembly插件)
- maven项目使用maven-assembly-plugin打包成可运行的jar
- Maven常用插件介绍:Maven-assembly-plugin插件
- Maven将依赖一起打包--使用maven-assembly-plugin
- 简历驱动开发(Resume Driven Development)
- SSM报错(二)Mybatis+c3p0+mysql报错mysql-connector-java 6.0.0
- Linux学习---7
- activiti学习--06流程变量:流程变量+变量的类型+流程变量api+设置流程变量1或2+查询流程变量的历史表
- 什么是hard negative mining
- maven java项目打包发布插件 maven-assembly-plugin
- vue饿了么学习-第七篇(组件拆分)
- java poi 生成excel模板
- 在配置文件中添加mime类型
- 第十五节:调用JS
- UVA 644
- tf.get_variable函数的使用
- Android 4.2 通过修改FrameWork源码实现动态隐藏导航栏,实现全屏
- 检索算法 ---二分查找