资讯专栏INFORMATION COLUMN

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

Tecode / 2236人阅读

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

基于gradle开发指南

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

</>复制代码

  1. buildscript {
  2. repositories {
  3. jcenter() // this applies only to the Gradle Shadow plugin
  4. }
  5. dependencies {
  6. classpath com.github.jengelman.gradle.plugins:shadow:2.0.4
  7. }
  8. }
  9. plugins {
  10. id java
  11. id application
  12. // shadow plugin to produce fat JARs
  13. id com.github.johnrengelman.shadow version 2.0.4
  14. }
  15. // artifact properties
  16. group = org.myorg.quickstart
  17. version = 0.1-SNAPSHOT
  18. mainClassName = org.myorg.quickstart.StreamingJob
  19. description = """Flink Quickstart Job"""
  20. ext {
  21. javaVersion = 1.8
  22. flinkVersion = 1.6.4
  23. scalaBinaryVersion = 2.11
  24. slf4jVersion = 1.7.7
  25. log4jVersion = 1.2.17
  26. }
  27. sourceCompatibility = javaVersion
  28. targetCompatibility = javaVersion
  29. tasks.withType(JavaCompile) {
  30. options.encoding = UTF-8
  31. }
  32. applicationDefaultJvmArgs = ["-Dlog4j.configuration=log4j.properties"]
  33. task wrapper(type: Wrapper) {
  34. gradleVersion = 3.1
  35. }
  36. // declare where to find the dependencies of your project
  37. repositories {
  38. mavenCentral()
  39. maven { url "https://repository.apache.org/content/repositories/snapshots/" }
  40. }
  41. // NOTE: We cannot use "compileOnly" or "shadow" configurations since then we could not run code
  42. // in the IDE or with "gradle run". We also cannot exclude transitive dependencies from the
  43. // shadowJar yet (see https://github.com/johnrengelman/shadow/issues/159).
  44. // -> Explicitly define the // libraries we want to be included in the "flinkShadowJar" configuration!
  45. configurations {
  46. flinkShadowJar // dependencies which go into the shadowJar
  47. // always exclude these (also from transitive dependencies) since they are provided by Flink
  48. flinkShadowJar.exclude group: org.apache.flink module: force-shading
  49. flinkShadowJar.exclude group: com.google.code.findbugs module: jsr305
  50. flinkShadowJar.exclude group: org.slf4j
  51. flinkShadowJar.exclude group: log4j
  52. }
  53. // declare the dependencies for your production and test code
  54. dependencies {
  55. // --------------------------------------------------------------
  56. // Compile-time dependencies that should NOT be part of the
  57. // shadow jar and are provided in the lib folder of Flink
  58. // --------------------------------------------------------------
  59. compile "org.apache.flink:flink-java:${flinkVersion}"
  60. compile "org.apache.flink:flink-streaming-java_${scalaBinaryVersion}:${flinkVersion}"
  61. // --------------------------------------------------------------
  62. // Dependencies that should be part of the shadow jar e.g.
  63. // connectors. These must be in the flinkShadowJar configuration!
  64. // --------------------------------------------------------------
  65. //flinkShadowJar "org.apache.flink:flink-connector-kafka-0.11_${scalaBinaryVersion}:${flinkVersion}"
  66. compile "log4j:log4j:${log4jVersion}"
  67. compile "org.slf4j:slf4j-log4j12:${slf4jVersion}"
  68. // Add test dependencies here.
  69. // testCompile "junit:junit:4.12"
  70. }
  71. // make compileOnly dependencies available for tests:
  72. sourceSets {
  73. main.compileClasspath += configurations.flinkShadowJar
  74. main.runtimeClasspath += configurations.flinkShadowJar
  75. test.compileClasspath += configurations.flinkShadowJar
  76. test.runtimeClasspath += configurations.flinkShadowJar
  77. javadoc.classpath += configurations.flinkShadowJar
  78. }
  79. run.classpath = sourceSets.main.runtimeClasspath
  80. jar {
  81. manifest {
  82. attributes Built-By: System.getProperty(user.name)
  83. Build-Jdk: System.getProperty(java.version)
  84. }
  85. }
  86. shadowJar {
  87. configurations = [project.configurations.flinkShadowJar]
  88. }
注解:注意修改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元查看
<