我正在尝试使用Scalapb (https://scalapb.github.io/docs/scalapbc/)生成Scalapb类。我能够生成scala文件,但获得以下错误。
com.huawei.utility.protobuff.embedtoRedis.embedtoRedis不符合类型参数界[A <:scalapb.GeneratedMessage with scalapb.MessageA]
Sample.proto
syntax = "proto2";
package protobuff;
message embedtoRedis {
required int32 StudentID = 1;
repeated float StudentTitle = 2;
required string Class = 3;
optional string color = 4;
required string Type = 5;
} 在使用下面的命令编译之后,我得到了两个scala类。ScalaPbc\scalapbc-0.11.1\bin>scalapbc.bat -v3.5.1 --scala_out=C:\Users\satheesh\Documents\ScalaPbc\new sample.proto
Scala类: EmbedtoRedis.scala SampleProto.scala
我在embedToRedis.scala中面对的问题有以下几行。
object embedtoRedis extends scalapb.GeneratedMessageCompanion[protobuff.sample.embedtoRedis] {
implicit def messageCompanion: scalapb.GeneratedMessageCompanion[protobuff.sample.embedtoRedis] = this
def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): protobuff.sample.embedtoRedis = {
var __requiredFields0: _root_.scala.Long = 0x7L
var __studentID: _root_.scala.Int = 0
val __studentTitle: _root_.scala.collection.immutable.VectorBuilder[_root_.scala.Float] = new _root_.scala.collection.immutable.VectorBuilder[_root_.scala.Float]
var ___class: _root_.scala.Predef.String = ""
var __color: _root_.scala.Option[_root_.scala.Predef.String] = _root_.scala.None
var __type: _root_.scala.Predef.String = ""错误: com.huawei.utility.protobuff.embedtoRedis.embedtoRedis类型参数不符合所生成的类型参数界[A <:scalapb.GeneratedMessage with scalapb.MessageA]
如果我遗漏了什么,你能帮忙吗?
发布于 2021-09-28 13:19:55
用于生成源文件的ScalaPB版本与编译时使用的版本不匹配。检查scalapbc工具(独立源生成器)和scalapb运行时版本是否匹配。
https://stackoverflow.com/questions/69350521
复制相似问题