maven插件: shade, assembly
Posted funny_coding
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven插件: shade, assembly相关的知识,希望对你有一定的参考价值。
shade插件的作用:
通过版本的exclution无法解决jar冲突的问题,
解决方案是把依赖的包打到本model的jar中,打包的时候由mvn plugin自动修改代码中的依赖jar包名
relocation配置会强制修改代码中的依赖包名 ==>
示例配置:
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
<promoteTransitiveDependencies>false</promoteTransitiveDependencies>
<createDependencyReducedPom>true</createDependencyReducedPom>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<minimizeJar>false</minimizeJar>
<createSourcesJar>false</createSourcesJar>
<artifactSet>
<includes>
<include>io.netty:netty-all</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>com.mytest.shade.io.netty</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
以上是关于maven插件: shade, assembly的主要内容,如果未能解决你的问题,请参考以下文章
idea打包jar的多种方式,用IDEA自带的打包形式,用IDEA自带的打包形式 用Maven插件maven-shade-plugin打包,用Maven插件maven-assembly-plugin打
使用maven-shade-plugin打包maven项目,项目使用spring框架,打包成jar时报错,跪求大佬,弄了好久没出?