Scala Play HTTP和gRPC

问题描述 投票:0回答:1

我有一个具有Scala Play的HTTP后端。工作良好。现在,我想在其之上设置一个gRPC-API(理论上这应该起作用)。

要设置gRPC,我基本上遵循了akka-quickstart

我可以运行sbt编译并将生成的Scala类存储在target /../ dic中。但是,如果我尝试运行sbt run,我会得到

--- (Running the application, auto-reloading is enabled) ---

[warn] a.u.ManifestInfo - You are using version 2.6.5 of Akka, but it appears you (perhaps indirectly) also depend on older versions of related artifacts. You can solve this by adding an explicit dependency on version 2.6.5 of the [akka-discovery] artifacts to your project. See also: https://doc.akka.io/docs/akka/current/common/binary-compatibility-rules.html#mixed-versioning-is-not-allowed
[error] java.lang.IllegalStateException: You are using version 2.6.5 of Akka, but it appears you (perhaps indirectly) also depend on older versions of related artifacts. You can solve this by adding an explicit dependency on version 2.6.5 of the [akka-discovery] artifacts to your project. See also: https://doc.akka.io/docs/akka/current/common/binary-compatibility-rules.html#mixed-versioning-is-not-allowed

所以我知道我使用的某些库对于Akka 2.6.5来说太老了,但我不知道如何在较低的Akka版本上设置我的服务。

我的plugins.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.2")
addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8-scaffold" % "0.11.0")
addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "1.0.0-M1")
resolvers += Resolver.bintrayRepo("playframework", "maven")
libraryDependencies += "com.lightbend.play" %% "play-grpc-generators" % "0.8.2"

我的build.sbt


name := "smartmarkt"
version := "1.0-SNAPSHOT"
scalaVersion := "2.13.2"

lazy val root = (project in file("."))
  .enablePlugins(PlayScala, PlayAkkaHttp2Support, AkkaGrpcPlugin)

import play.grpc.gen.scaladsl.PlayScalaServerCodeGenerator
akkaGrpcExtraGenerators += PlayScalaServerCodeGenerator
libraryDependencies += "com.lightbend.play" %% "play-grpc-runtime" % "0.8.2"

libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % Test
scala playframework akka akka-http akka-grpc
1个回答
0
投票

查看您的直接依赖项:

["com.lightbend.play" %% "play-grpc-runtime" % "0.8.2"取决于akka-discovery 2.6.4。

您使用的是Play 2.8.2,具体取决于Akka版本2.6.5。

只需将依赖于akka-discovery 2.6.5的依赖项添加到您的依赖项中:

libraryDependencies += "com.typesafe.akka" %% "akka-discovery" % "2.6.5"
© www.soinside.com 2019 - 2024. All rights reserved.