Java Maven GRPC编译 引入其他proto Tried to write the same file twice或者xx is not defined.错误
报错信息:
grpc maven 编译 Error: java:: Tried to write the same file twice.
PROTOC FAILED: Account.proto:90:5: “Ret” is not defined.
引入其他proto时:
- 同目录使用 import “Enums.proto”;
- package要和被引入的相同
- 某个proto引入Enums.proto
syntax = "proto3";
import "Enums.proto";
option java_multiple_files = true;
option java_package = "com.company.strategy";
option java_outer_classname = "Strategy";
option objc_class_prefix = "company";
package strategy;
- Enums.proto
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.company.quantitative_trading_account";
option java_outer_classname = "Enums";
option objc_class_prefix = "company";
package strategy;
enum SubscribeType{
//占位
SubscribeType_ZERO = 0;
//订阅
SUBSCRIBE = 1;
//取消订阅
UNSUBSCRIBE = 2;
}
....
保持package相同,以及没有重复两个里头都写有相同message/enum即可编译通过
本文来自博客园,作者:HumorChen99,转载请注明原文链接:https://www.cnblogs.com/HumorChen/p/18039650