0

我在 scala 上有带有示例 protobuf 的简单代码

原型文件

syntax = "proto3";

package grpc.example;

message HelloRequest {
  string msg = 1;
  int32 code = 2;
}


message HelloResponse {
  string msg = 1;
}

service HelloWorld {
  rpc hello (HelloRequest) returns (HelloResponse);
}

项目文件夹中的 plugins.sbt

addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.0")

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.10.10"

构建.sbt


name := "custom-grpc"

version := "0.1"

scalaVersion := "2.13.4"


lazy val protoExample = (project in file("proto-example"))
  .settings(

    PB.targets in Compile := Seq(
      scalapb.gen() -> (sourceManaged in Compile).value / "scalapb"
    ),
    libraryDependencies ++= Seq(
      "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"
    ),
    scalaVersion := "2.13.4"
  )


lazy val root = (project in file("."))
  .aggregate(protoExample)

在 sbt shell 调用命令编译时出现错误

[info] Compiling schema C:\Users\<.....>\IdeaProjects\LearnScala\custom-grpc\proto-example\src\main\protobuf\hello.proto
Error: Could not find or load main class protocbridge.frontend.BridgeApp
--jvm_0_out: protoc-gen-jvm_0: Plugin failed with status code 1.

什么是错误???我使用的是 Windows10 和 jdk 1.8,然后是 jdk 11。

4

0 回答 0