在 .proto 文件中使用导入时出错 [英] Error using import in .proto file

查看:25
本文介绍了在 .proto 文件中使用导入时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 import 语句将名为 test1.proto 的 proto 文件导入另一个名为 test2.proto 的 proto 文件

I tried importing a proto file named test1.proto to another proto file named test2.proto using the import statement

import "com/test/test1.proto";

但我收到以下错误

com/test/test1.proto: File not found.
test2.proto: Import "com/test/test1.proto" was not found or had errors.

我尝试了很多方法来找到导入错误的原因,但找不到.那么如果上述语句有问题,有人可以告诉我进行 proto 文件导入的正确方法吗??

I tried in many ways to find the cause of the import error but couldn't. So could someone please tell me the correct way of doing proto file imports in case there is something wrong with the above statement??

推荐答案

你必须使用 --proto_path 命令行标志(又名 -I)来告诉protoc 在哪里查找 .proto 文件.如果不提供路径,默认情况下它只会搜索当前目录.请参阅文档(在本文档末尾的生成您的类"下)page),或输入 protoc --help.

You have to use the --proto_path command-line flag (aka -I) to tell protoc where to look for .proto files. If you don't provide a path, by default it will only search the current directory. See the documentation (under "Generating Your Classes" at the end of the page), or type protoc --help.

这篇关于在 .proto 文件中使用导入时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆