maven打依赖包问题解决排查

由于spark程序运行在yarn上经常需要把依赖的包打进jar里,网上查了下需要添加maven插件

插件代码如下:

<build>
        <plugins>

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
<!--            <version>3.6.0</version>-->
            <configuration>
<!--                <source>1.8</source>-->
<!--                <target>1.8</target>-->
<!--                <encoding>utf-8</encoding>-->
                <archive>
                    <manifest>
                        <mainClass>com.xxx.xxx.HbaseProxyApplication.main</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            </plugin>
        </plugins>
    </build>

好,正常情况下是不会有啥问题的,但是人生总是如此的困难,我遇到了报错。。。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (make-assembly) on project hbase-proxy-spark: Failed to create assembly: Error creating assembly archive jar-with-dependencies: Problem creating jar: Unexpected end of ZLIB input stream -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

百度了N久,最后得出的结论就是,jar包有问题,但是不知道是哪段代码报错呀,要如何排查呢,跟着报错提示走呗。 re-run Maven with the -e switch.在打包的时候加上-e参数康康哪里报的错

这下知道是哪里报的错了,点进去看看,再加上度娘,让我理解到了这段代码应该是读依赖的jar包的代码在这里打个断点,然后怀着万物皆可debug的心情打开了debug编辑器,结果好家伙,maven打包也可以debug

赶紧上手试试,断点生效

由下面debug信息啥都可以看到啦~~~ 我们可以看到,依赖包的maven库本地地址,那个包那个类被进行压缩,秉着好奇我看看再libraries看看这类怎么了

打开来直接好家伙。。。一片空白。。。现在把对应maven本地库的jar包删了后刷新试试。

代码在调用着这个包结束掉代码的debug就可以删了,刷新后。。。好家伙。。代码出来了

总结一下,这个问题就是maven 调用Jdk的方法去加载jar包的方法加载不到,要把jar包删了从远程仓库从新下载就Ok了,至于jar包类里的代码为啥是空白。。我也不知道呀,估计是网络问题导致下载jar包时里面代码缺失,反正删了重下就有了,就这样经过我一个个排查后。。最终打出了带依赖的maven包(泪目。。。)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值