Flink入门篇-编译源码(上)

    技术2023-09-02  113

    前置

    所需环境版本java“11” 2018-09-25scala2.11.12maven3.5.2windowswin10 家庭版flinklast commit-id 7df486e4 (master)

    下载源码

    git clone https://github.com/apache/flink

    这个应该得等一会儿 此刻抽根烟。。。

    进行编译

    1. 进入dos界面 win+r 2. 进入源码根目录 cd C:\Users\18380\myself\coder\flink 3. 执行命令 mvn clean install -DskipTests -Drat.skip=true

    看到这个页面的时候,那么恭喜你,编译成功了,如果你没有遇到问题,那你应该去买彩票了,如遇到下面问题,可以参考。

    编译问题集锦

    1.Too many files with unapproved license: 2

    [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.393 s [INFO] Finished at: 2020-07-01T06:47:43+08:00 [INFO] Final Memory: 79M/277M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.rat:apache-rat-plugin:0.12:check (default) on project flink-parent: Too many files with unapproved license: 2 See RAT report in: C:\Users\18380\myself\coder\flink\target\rat.txt -> [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/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :flink-parent

    解决办法就是跳过认证:

    加上 -Drat.skip=true 即 mvn clean install -DskipTests -Drat.skip=true

    2.Failed to execute goal on project flink-avro-confluent-registry: Could not resolve dependencies

    [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:10 h [INFO] Finished at: 2020-07-03T23:23:14+08:00 [INFO] Final Memory: 383M/1304M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project flink-avro-confluent-registry: Could not resolve dependencies for project org.apache.flink:flink-avro-confluent-registry:jar:1.12-SNAPSHOT: Failure to find io.confluent:kafka-schema-registry-client:jar:4.1.0 in http://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-aliyun has elapsed or updates are forced -> [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/DependencyResolutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :flink-avro-confluent-registry

    解决办法: 分析: 此类问题,就是没在远程仓库里面找到对应的包,那么就手动去找到并且下载。

    找到下载地址: http://packages.confluent.io/maven/io/confluent/kafka-schema-registry-client/4.1.0/

    将上面的包下载下来之后放到该路径下(根据你的本地地址是什么,相对地址一定要填写正确好,mvn编译的时候会去对应的坐标找包)

    没有下面的这个路径的话,就自己创建 .m2\repository\io\confluent\kafka-schema-registry-client\4.1.0

    如下图所示: 然后再次执行下面的命令

    mvn clean install -DskipTests -Drat.skip=true

    终于编译成功了,磕磕绊绊的。下篇就是将编译好的包部署测试一下。

    Processed: 0.008, SQL: 9