资讯专栏INFORMATION COLUMN

【Flink实时计算 UFlink】基于gradle开发指南

Tecode / 1908人阅读

摘要:基于开发指南如果基于进行应用开发,需要在文件中加入如下配置注解注意修改的值,确保其符合您的应用。应用开发完成后,可以直接直接运行方法,在本地进行基本的测试。

基于gradle开发指南

如果基于gradle进行应用开发,需要在build.gradle文件中加入如下配置:

buildscript {
    repositories {
        jcenter() // this applies only to the Gradle Shadow plugin
    }
    dependencies {
        classpath com.github.jengelman.gradle.plugins:shadow:2.0.4
    }
}

plugins {
    id java
    id application
    // shadow plugin to produce fat JARs
    id com.github.johnrengelman.shadow version 2.0.4
}


// artifact properties
group = org.myorg.quickstart
version = 0.1-SNAPSHOT
mainClassName = org.myorg.quickstart.StreamingJob
description = """Flink Quickstart Job"""

ext {
    javaVersion = 1.8
    flinkVersion = 1.6.4
    scalaBinaryVersion = 2.11
    slf4jVersion = 1.7.7
    log4jVersion = 1.2.17
}


sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) {
    options.encoding = UTF-8
}

applicationDefaultJvmArgs = ["-Dlog4j.configuration=log4j.properties"]

task wrapper(type: Wrapper) {
    gradleVersion = 3.1
}

// declare where to find the dependencies of your project
repositories {
    mavenCentral()
    maven { url "https://repository.apache.org/content/repositories/snapshots/" }
}

// NOTE: We cannot use "compileOnly" or "shadow" configurations since then we could not run code
// in the IDE or with "gradle run". We also cannot exclude transitive dependencies from the
// shadowJar yet (see https://github.com/johnrengelman/shadow/issues/159).
// -> Explicitly define the // libraries we want to be included in the "flinkShadowJar" configuration!
configurations {
    flinkShadowJar // dependencies which go into the shadowJar

    // always exclude these (also from transitive dependencies) since they are provided by Flink
    flinkShadowJar.exclude group: org.apache.flink module: force-shading
    flinkShadowJar.exclude group: com.google.code.findbugs module: jsr305
    flinkShadowJar.exclude group: org.slf4j
    flinkShadowJar.exclude group: log4j
}

// declare the dependencies for your production and test code
dependencies {
    // --------------------------------------------------------------
    // Compile-time dependencies that should NOT be part of the
    // shadow jar and are provided in the lib folder of Flink
    // --------------------------------------------------------------
    compile "org.apache.flink:flink-java:${flinkVersion}"
    compile "org.apache.flink:flink-streaming-java_${scalaBinaryVersion}:${flinkVersion}"

    // --------------------------------------------------------------
    // Dependencies that should be part of the shadow jar e.g.
    // connectors. These must be in the flinkShadowJar configuration!
    // --------------------------------------------------------------
    //flinkShadowJar "org.apache.flink:flink-connector-kafka-0.11_${scalaBinaryVersion}:${flinkVersion}"

    compile "log4j:log4j:${log4jVersion}"
    compile "org.slf4j:slf4j-log4j12:${slf4jVersion}"

    // Add test dependencies here.
    // testCompile "junit:junit:4.12"
}

// make compileOnly dependencies available for tests:
sourceSets {
    main.compileClasspath += configurations.flinkShadowJar
    main.runtimeClasspath += configurations.flinkShadowJar

    test.compileClasspath += configurations.flinkShadowJar
    test.runtimeClasspath += configurations.flinkShadowJar

    javadoc.classpath += configurations.flinkShadowJar
}

run.classpath = sourceSets.main.runtimeClasspath

jar {
    manifest {
        attributes Built-By: System.getProperty(user.name)
                Build-Jdk: System.getProperty(java.version)
    }
}

shadowJar {
    configurations = [project.configurations.flinkShadowJar]
}
注解:注意修改mainClassName的值,确保其符合您的应用。应用开发完成后,可以直接直接运行main方法,在本地进行基本的测试。如果已经完成开发测试,则直接运行shadowJar即可。

实时文档欢迎https://docs.ucloud.cn/uflink/dev/gradle

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/126203.html

相关文章

  • Flink实时计算 UFlink基于Maven开发指南

    摘要:基于开发指南本节主要介绍如何创建项目,并开发简单的应用,从而使该应用可以被提交到平台运行。如果不设置为,可能会导致的类冲突,产生不可预见的问题。在自动生成的文件中,使用了来更方便的控制依赖的可见性。基于Maven开发指南本节主要介绍如何创建项目,并开发简单的Flink应用,从而使该Flink应用可以被提交到UFlink平台运行。==== 自动生成代码框架 ==== 对于Java开发者,可以使...

    Tecode 评论0 收藏0
  • Flink实时计算 UFlink】UFlink开发注意事项

    摘要:开发注意事项基于托管集群的应用开发,和自建集群类似,但是仍然有几个地方需要注意。和默认配置托管集群默认指定以及的堆大小为,目前不支持进行更改单个中的数量设置为高可用配置应用的高可用由集群以及共同保证。配置集群的运行时状态保存在的指定目录中。UFlink开发注意事项基于UFlink托管集群的Flink应用开发,和自建集群类似,但是仍然有几个地方需要注意。JobManager和TaskManag...

    Tecode 评论0 收藏0
  • Flink实时计算 UFlink】什么是实时计算、产品优势、版本支持

    摘要:什么是实时计算实时计算基于构建,为分布式高性能随时可用以及准确的流处理应用程序提供流处理框架,可用于流式数据处理等应用场景。版本支持当前支持的版本为,,,可以在提交任务时选择所使用的版本。什么是实时计算实时计算(UFlink)基于ApacheFlink构建,为分布式、高性能、随时可用以及准确的流处理应用程序提供流处理框架,可用于流式数据处理等应用场景。产品优势100%开源兼容基于开源社区版本...

    Tecode 评论0 收藏0
  • Flink实时计算 UFlink】UFlink SQL 开发指南

    摘要:开发指南是为简化计算模型,降低用户使用实时计算的门槛而设计的一套符合标准语义的开发套件。随后,将为该表生成字段,用于记录并表示事件时间。UFlink SQL 开发指南UFlink SQL 是 UCloud 为简化计算模型,降低用户使用实时计算的门槛而设计的一套符合标准 SQL 语义的开发套件。接下来,开发者可以根据如下内容,逐渐熟悉并使用 UFlink SQL 组件所提供的便捷功能。1 ...

    Tecode 评论0 收藏0
  • Flink实时计算 UFlink】集群管理

    摘要:集群管理进入集群管理页面通过集群列表页面进入集群管理页面获取集群详情通过集群列表的详情按钮进入详情页面调整集群大小点击调整容量调整集群大小查看点击详情页的按钮查看查看任务历史点击详情页的按钮查看历史任务节点密码重置点击集群列表页的集群管理1. 进入集群管理页面通过UFlink集群列表页面进入集群管理页面:2. 获取集群详情通过集群列表的详情按钮进入详情页面:3. 调整集群大小点击调整容量调整...

    Tecode 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<