在 .proto 文件中使用导入时出错

编程入门 行业动态 更新时间:2024-10-23 13:38:59
本文介绍了在 .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屋!

更多推荐

[db:关键词]

本文发布于:2023-03-31 17:11:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/808842.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   proto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!