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

限于喜欢 提交于 2020-12-12 05:44:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!