问题:项目需要用到的两个依赖都用到了com.google.guava,由于guava的版本在16.0以后,不向后兼容,
这就导致出现了一个比较尴尬的地方 :一个需要guava版本<=16.0,一个需要guava版本>=20.0
解决方案:使用 maven-shade-plugin 打包,并且修改依赖中冲突的包名,这样hbase引用的就是修改包名后的guava包了,不再依赖原生的guava包。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>com.google.guava</pattern>
<shadedPattern>com.shade.google.guava</shadedPattern>
</relocation>
<relocation>
<pattern>org.joda</pattern>
<shadedPattern>org.shaded.joda</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.common</pattern>
<shadedPattern>com.shade.google.common</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.thirdparty</pattern>
<shadedPattern>com.shade.google.thirdparty</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.protobuf</pattern>
<shadedPattern>com.shade.google.protobuf</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
ps:shade打包后可以直接看到修改包名的相关类的package已经生效,package com.shade.google.protobuf;
遇到的其他问题:打包后的jar文件大小超过50M,上传到maven私有仓库失败,需要联系运维来解决了
Return code is: 413, ReasonPhrase: Request Entity Too Large. -> [Help 1]因为Nginx做了maven.allure.so的端口分发,所有的流量都会流经Nnginx后到达Nexus,而在Nginx层面,http的包大小默认做了限制。
1253

被折叠的 条评论
为什么被折叠?



