在Java协议缓冲区中导入“ googleprotobufdescriptor.proto”

在Java协议缓冲区中导入“ googleprotobufdescriptor.proto”,第1张

在Java协议缓冲区中导入“ google / protobuf / descriptor.proto”

当我在.proto中使用描述符时,我像

import "google/protobuf/descriptor.proto";message AddressBook {  required google.protobuf.FileDescriptorSet proto_files = 1;

然后使用默认目录下的addressbookSD.proto生成Java(在Windows上):

protoc addressbookSD.proto --java_out=./ --proto_path=./ --proto_path=<protobuf-install-directory>src

其中,< protobuf-install-directory >是协议缓冲区安装目录。关键是描述符.proto在

<protobuf-install-directory>srcgoogleprotobuf

protobuf导入策略中的级别必须与文件系统中的目录匹配,就像在Java中一样。

因此,我使用< protobuf-install-directory > src作为导入目录,目录结构必须为

<protobuf-install-directory>src    +-- google         +-- protobuf  +-- descriptor.proto


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5601364.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存