我的 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 compile
但我得到编译错误
[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