scala - 如何解决在 Windows10 的 scala 项目中编译 protobuf 的问题?
问题描述
我在 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。
解决方案
推荐阅读
- python - 从网络摄像头流openCV中隔离并显示红色通道
- python - 具有验证和字符替换的多行文本小部件
- php - 需要用于 Google Oauth2 登录的 PHP 配方
- html - 在 HTML 字符串 (NodeJs) 中展开不必要的嵌套 div
- ios - 无法从 Cocoapods 渲染 SwiftUI 预览
- oracle - sqlplus 连接本地 Oracle 失败。连接失败,因为目标主机或对象不存在
- javascript - Javascript 在旧的 Windows Firefox 上失败
- asp.net-core - DotNet Core 3 EF 3 与 Cosmos DB 问题
- xml - 使用 xslt 替换 xml 中的值
- android - 无法连接到运行 Oreo 的 google android 模拟器上的端口