Scala Flink Watermarker Error: Static Methods in interface require -target:jvm-1.8

explain

Gradle project + Scala 2.11 + java8 + Flink 1.12

Error code:

kafkaSource.assignTimestampsAndWatermarks(WatermarkStrategy
      .forBoundedOutOfOrderness[JSONObject](Duration.ofSeconds(10)))

Error message: static methods in interface require – target: jvm-1.8

From the perspective of error reporting, it is an error reported by Scala trying to call a static method in the java interface. However, JDK1.8 is used for compiling and packaging in the idea configuration

Modifying the following idea configuration is not valid:

So think about another breakthrough and add the following configuration to the build.gradle file to solve the problem.

project.tasks.compileScala.scalaCompileOptions.additionalParameters = ["-target:jvm-1.8"]
project.tasks.compileTestScala.scalaCompileOptions.additionalParameters = ["-target:jvm-1.8"]

Read More: