如何修复接口中的“静态方法需要-target:jvm-1.8"?在Scala应用程序中? [英] How to fix "static methods in interface require -target:jvm-1.8" in Scala application?
本文介绍了如何修复接口中的“静态方法需要-target:jvm-1.8"?在Scala应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了以下代码:
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()
最后,我在build.sbt文件中使用了以下依赖项
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版本为1.8,Scala版本为2.11.12.知道了,如何解决这个问题?
Java version is 1.8, and Scala version is 2.11.12. Any idea, how to fix this please?
推荐答案
请在您的build.sbt
中添加以下内容:
Please add the following into your build.sbt
:
scalacOptions in ThisBuild += "-target:jvm-1.8"
在Gradle的接口中的静态方法需要-target:jvm-1.8 .
这篇关于如何修复接口中的“静态方法需要-target:jvm-1.8"?在Scala应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文