java – 如何在单个命令中编译多个proto文件?
发布时间:2020-12-14 16:24:21 所属栏目:Java 来源:网络整理
导读:我在单个目录中有两个proto文件,我正在寻找一种方法,可以在单个命令中从这些文件生成类. Protobuf文档说我们需要使用–proto_path参数. C:shekharproto_trialdir Volume in drive C is C Directory of C:shekharproto_trial07/25/2014 12:16 PM DIR .07/
我在单个目录中有两个proto文件,我正在寻找一种方法,可以在单个命令中从这些文件生成类. Protobuf文档说我们需要使用–proto_path参数.
C:shekharproto_trial>dir Volume in drive C is C Directory of C:shekharproto_trial 07/25/2014 12:16 PM <DIR> . 07/25/2014 12:16 PM <DIR> .. 07/25/2014 12:16 PM <DIR> java_op 07/25/2014 12:16 PM 230 map.proto 07/23/2014 04:24 PM 161 message.proto 07/25/2014 12:17 PM 1,228 response.proto 3 File(s) 1,619 bytes 3 Dir(s) 50,259,398,656 bytes free 我使用了–proto_path参数,如下所示 C:shekharproto_trial>protoc --proto_path=C:shekharproto_trial --java_out=C:shekharproto_trialjava_op *.proto 但我得到以下错误 message.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think). 请建议一些单独编译所有原型文件的方法. 解决方法
问题是您将–proto_path指定为绝对路径,但将proto文件指定为相对路径.您可以删除–proto_path参数(无论如何都默认为当前目录),或者您可以执行以下操作:
protoc --proto_path=C:shekharproto_trial --java_out=C:shekharproto_trialjava_op C:shekharproto_trial*.proto (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |