栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在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


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/596060.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号