jprotobuf icon indicating copy to clipboard operation
jprotobuf copied to clipboard

带import 的 proto 生成Java报错

Open wjm0729 opened this issue 7 years ago • 1 comments

ProtobufIDLProxy.generateSource(protoPath, javaOutPath); proto文件有import 会生成失败。 如下 生成 ProtobufIDLProxy.generateSource("./PlayerInfo.proto", "./out"); Exception in thread "main" java.lang.RuntimeException: Message 'PlayerInfo' depend on message 'ItemInfo' is missed at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.hasDependency(ProtobufIDLProxy.java:630) at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.createMessageClass(ProtobufIDLProxy.java:440) at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.doCreatePro(ProtobufIDLProxy.java:343) at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.doCreatePro(ProtobufIDLProxy.java:382) at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.generateSource(ProtobufIDLProxy.java:287) at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.generateSource(ProtobufIDLProxy.java:281) at JprotobufTest.main(JprotobufTest.java:19)

proto 文件如下:

PlayerInfo.proto

syntax = "proto3"; import "ItemInfo.proto"; package Proto.Generate; message PlayerInfo { int64 uid=1; string accountId=2; string name=3; int64 createTime=4; string pf=5; int32 level=6; int64 exp=7; int32 diamonds=8; int32 superiors=9; int32 gold=10; int32 silver=11; repeated ItemInfo items=12; }

ItemInfo.proto

syntax = "proto3"; package Proto.Generate; message ItemInfo { int64 itemId=1; int64 uid=2; int32 templateId=3; int32 count=4; int64 createTime=5; int32 para1=6; int64 para2=7; }

wjm0729 avatar Apr 16 '17 14:04 wjm0729

fixed at 1.10.5 and 2.1.0

xiemalin avatar Apr 18 '17 06:04 xiemalin