问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/65197661/how-to-fix-static-methods-in-interface-require-targetjvm-1-8-in-scala-applic