Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "static methods in interface require -target:jvm-1.8" in Scala application?

I wrote the following code:

import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient

class Test() extends CloudWatchLogsClient {
  CloudWatchLogsClient.builder().build()
  def close():Unit = {
    println("test")
  }

  def serviceName(): String  = "serviceName"
  CloudWatchLogsClient.create()
}

When it comes to compiling , I get the following error:

Static methods in interface require -target:jvm-1.8
  CloudWatchLogsClient.builder().build()

Finally, I used the following dependencies in my build.sbt file

libraryDependencies += "software.amazon.awssdk" % "cloudwatch" % "2.15.40",
libraryDependencies += "software.amazon.awssdk" % "cloudwatchlogs" % "2.15.40"

Java version is 1.8, and Scala version is 2.11.12. Any idea, how to fix this please?

like image 967
scalacode Avatar asked Sep 21 '25 09:09

scalacode


1 Answers

Please add the following into your build.sbt:

scalacOptions in ThisBuild += "-target:jvm-1.8"

There is a similar question asking about the same error at Gradle at Static methods in interface require -target:jvm-1.8.

like image 93
Tomer Shetah Avatar answered Sep 23 '25 06:09

Tomer Shetah