protobuf导入其他proto文件

需求:
文件A.proto需要B.proto文件中的某enum类型

1、import导入
需要在A.proto文件中导入B.proto文件,相当于c里的include;
import “xxx/xxxx/proto/B.proto”;

B.proto文件
package spark.testB;

message messageB {

enum Type{
};

};

2、编译路径
bazel编译中要包含B.proto的路径
deps = [
“//xxx/xxxx/proto:xxxx_lib”,
],
3、message或enum调用

A.proto调用B.proto
A.proto文件

package spark.testA;
import “xxx/xxxx/proto/B.proto”;

message messageA {

testB.messageB.Type type;

};

参考链接:https://blog.csdn.net/zhangmiaoping23/article/details/99683650
https://blog.csdn.net/xp178171640/article/details/103046873

猜你喜欢

转载自blog.csdn.net/zhiyijue7762/article/details/106194061
今日推荐