shade打包解决guava版本冲突

问题:项目需要用到的两个依赖都用到了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的包大小默认做了限制。

转载于:https://my.oschina.net/jeakiry/blog/2964169

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值