我正在嘗試使用 scalaPB 的官方示例來實作簡單的服務器-客戶端應用程式。scala 代碼可以在他們的gitHub上找到
但是,當我嘗試運行它時,object helloworld is not a member of package io.grpc.examples.helloworld當我嘗試使用import io.grpc.examples.helloworld.helloworld.{foo}.
我的 build.sbt 檔案:
name := "Distributed sorting"
version := "0.1"
scalaVersion := "2.13.7"
libraryDependencies = Seq(
"io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion,
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion
)
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
)
我的檔案如下所示:
├── build.sbt
├── project
│ ├── build.properties
│ ├── scalapb.sbt
│ └── target
├── ...
└── src/main
├── protobuf
├── hello.proto
└── scala/io/grpc/examples/helloworld
├── HelloWorldClient.scala
└── HelloWorldServer.scala
uj5u.com熱心網友回復:
首先,我推薦使用Akka gRPC而不是直接使用 ScalaPB。該檔案非常清楚,并且有一個gter8 配置可用于使用.gitignore創建示例專案sbt new。
其次,那個 gitHub 中的代碼看起來不像官方示例代碼。它說它是“從 grpc java 翻譯的”,這可能不是你想要的。
最后,在您看到的特定問題上,scalaPB 生成的存根位于一個包中,該包的名稱在proto檔案中給出。示例檔案有
package com.example.protos
所以存根將在com.example.protos.Greeter.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/366272.html
上一篇:將物件串列轉換為其欄位串列
