gpt4 book ai didi

scala - 无法编译 scrooge thrift 插件生成的源代码

转载 作者:行者123 更新时间:2023-12-01 16:30:31 27 4
gpt4 key购买 nike

我的plugins.sbt是

addSbtPlugin("com.twitter" % "scrooge-sbt-plugin" % "4.8.0")

我的build.sbt是

val finagleVersion = "6.45.0"

lazy val myProject = Project("FinagleTest", file("."))
.settings(
name := "FinagleTest",
version := "1.0",
scalaVersion := "2.12.2",
libraryDependencies ++= Seq(
"org.apache.thrift" % "libthrift" % "0.9.2",
"com.twitter" %% "scrooge-core" % "4.18.0" exclude("com.twitter", "libthrift"),
"com.twitter" %% "finagle-thrift" % finagleVersion exclude("com.twitter", "libthrift"),
"com.twitter" %% "finagle-http" % finagleVersion,
"com.twitter" %% "finagle-core" % finagleVersion
),
scroogeThriftSourceFolder in Compile := {
val base = baseDirectory.value
base / "src/main/thrift"
}
)

src/main/thrift文件夹中创建temprature_service.thrift文件

namespace * com.foo.temprature.thrift
struct TempratureDatum {
1: i32 celcius,
2: i64 timestamp
}

service TempratureService {
void add(1: TempratureDatum datum);
double mean();
}

并使用sbt clean scrooge-gen编译

进行编译

但是我遇到编译错误

[info] Compiling 5 Scala sources to /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/classes...
[error] /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/src_managed/main/com/foo/temprature/thrift/TempratureDatum.scala:481: value _equals is not a member of object scala.runtime.ScalaRunTime
[error] _root_.scala.runtime.ScalaRunTime._equals(this, other) &&
[error] ^
[error] /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/src_managed/main/com/foo/temprature/thrift/TempratureService.scala:65: type mismatch;
[error] found : com.twitter.finagle.Service[com.foo.temprature.thrift.TempratureService.Add.Args,com.foo.temprature.thrift.TempratureService.Add.SuccessType]
[error] (which expands to) com.twitter.finagle.Service[com.foo.temprature.thrift.TempratureService.Add.Args,Unit]
[error] required: com.twitter.finagle.Service[com.foo.temprature.thrift.TempratureService.Add.Args,com.foo.temprature.thrift.TempratureService.Add.Result]
[error] add = ThriftServiceIface(self.Add, binaryService, pf, stats),
[error] ^
[error] /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/src_managed/main/com/foo/temprature/thrift/TempratureService.scala:66: type mismatch;
[error] found : com.twitter.finagle.Service[com.foo.temprature.thrift.TempratureService.Mean.Args,com.foo.temprature.thrift.TempratureService.Mean.SuccessType]
[error] (which expands to) com.twitter.finagle.Service[com.foo.temprature.thrift.TempratureService.Mean.Args,Double]
[error] required: com.twitter.finagle.Service[com.foo.temprature.thrift.TempratureService.Mean.Args,com.foo.temprature.thrift.TempratureService.Mean.Result]
[error] mean = ThriftServiceIface(self.Mean, binaryService, pf, stats)
[error] ^
[error] /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/src_managed/main/com/foo/temprature/thrift/TempratureService.scala:248: value _equals is not a member of object scala.runtime.ScalaRunTime
[error] _root_.scala.runtime.ScalaRunTime._equals(this, other) &&
[error] ^
[error] /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/src_managed/main/com/foo/temprature/thrift/TempratureService.scala:373: value _equals is not a member of object scala.runtime.ScalaRunTime
[error] _root_.scala.runtime.ScalaRunTime._equals(this, other) &&
[error] ^
[error] /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/src_managed/main/com/foo/temprature/thrift/TempratureService.scala:524: value _equals is not a member of object scala.runtime.ScalaRunTime
[error] _root_.scala.runtime.ScalaRunTime._equals(this, other) &&
[error] ^
[error] /Users/Foo/IdeaProjects/FinagleTest/target/scala-2.12/src_managed/main/com/foo/temprature/thrift/TempratureService.scala:705: value _equals is not a member of object scala.runtime.ScalaRunTime
[error] _root_.scala.runtime.ScalaRunTime._equals(this, other) &&
[error] ^
[error] 7 errors found

最佳答案

有趣的是,今天我正在编写另一个节俭服务,我发现了这个问题,这是我一年前发布的:)

幸运的是,解决方案非常简单。

上面代码中使用的插件版本非常旧。

您可以在此处找到该插件的最新版本

https://bintray.com/twittercsl/sbt-plugins/scrooge-sbt-plugin

如果我将plugins.sbt 文件更新为

,问题就会得到解决
addSbtPlugin("com.twitter" % "scrooge-sbt-plugin" % "18.4.0")

关于scala - 无法编译 scrooge thrift 插件生成的源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45539048/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com