flink 继承 hadoop3 编译实践

由于 hadoop 升级,flink 使用 1.8 版本,需要自定义编译继承 hadoop 3.3.1。

由于历史原因,使用的 flink 版本较低,建议大家使用 flink 1.10 及以上的版本。

一、编译 flink

1、下载源码

git clone -b release-1.8 https://github.com/apache/flink.git

注意:可根据依赖的 flink 版本,切换到对应的分支。

2、编译源码

# skip test

mvn clean install -DskipTests

# 快速编译,skip test、QA、document 等

mvn clean install -DskipTests -Dfast

二、编译 flink-shaded

如果项目需要使用到 hadoop 环境,则需要集成 hadoop 依赖。官方有提供一些 hadoop 版本的集成包,可以将依赖包引入到项目中,或者放置到 flink/lib 目录下。

https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/

第一串数字表示 hadoop 版本,第二串数据表示 flink 版本

 因为我们使用的 hadoop 版本为 3.3.1,不在官方提供的范围中,需要我们自己打包编译。

1、下载源码

git clone -b release-8.0 https://github.com/apache/flink-shaded.git

注意:可根据依赖的 flink 版本,切换到对应的分支。

2、编译源码

mvn clean install -Dhadoop.version=3.3.1

注意:如果需要指定hadoop的发行商,需要使用-Pvendor-repos。前提是maven仓库增加了对应发行商的仓库地址,使用帮助见 maven说明
如:

mvn clean install -Pvendor-repos -Dhadoop.version=3.0.0-cdh6.2.0

三、遇到的问题

1、Error creating shaded jar: null: IllegalArgumentException

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.0.0:shade (shade-flink) on project flink-shaded-hadoop-2-uber: Error creating shaded jar: null: IllegalArgumentException -> [Help 1]

解决办法:升级所有 maven-shade-plugin 版本至 3.2.1

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>

2、Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test 

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project web_nanchang: There are test failures.

[ERROR]

[ERROR] Please refer to E:\maven\web_nanchang\target\surefire-reports for the individual test results.

因为测试代码时遇到错误,它会停止编译。只需要在提示错误模块的pom.xml的<project>里添加以下配置,使得测试出错不影响项目的编译。 

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
            </configuration>
        </plugin>
    </plugins>
</build>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

magic_kid_2010

你的支持将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值