<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<id>shade-hessian</id>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>hessian:hessian</include>
</includes>
</artifactSet>
<createSourcesJar>true</createSourcesJar>
<relocations>
<relocation>
<pattern>com.caucho</pattern>
<shadedPattern>com.alibaba.dubbo.hsf.hessian.v3_0_14_bugfix</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
上面的配置把 groupId 为 hessian artifactId 也为 hessian 的依赖中 com.caucho 包下面的所有类重命名为 com.alibaba.dubbo.hsf.hessian.v3_0_14_bugfix 后和项目中的类文件一起打到 jar 包中。
maven 2 就是通过这种方式打包的,可以看一下 maven 2 安装目录下 lib 目录中的那个 jar。
施用 maven shade plugin 解决 jar 或类的多版本冲突
原文:http://www.cnblogs.com/zhujiabin/p/5115703.html