【发布时间】:2019-07-11 05:24:45
【问题描述】:
我需要在哪里将path 设置为protoc 以获取导入标准协议缓冲区(protobuf),例如Windows 和Dart 中的empty.proto 和timestamp.proto?
protoc 运行时:
protoc --dart_out=grpc:lib/src/protos/generated -Iprotos 原型/组织.proto --plugin=protoc-gen-dart=D:\Users\Samuel\AppData\Roaming\Pub\Cache\bin\protoc-gen-dart.bat
出现以下错误:
google/protobuf/empty.proto:找不到文件。组织.proto: 未找到导入“google/protobuf/empty.proto”或出现错误。 organization.proto:14:27:“google.protobuf.Empty”未定义。
在 Protobuf Support 插件上的 IntelliJ Settings 中,path 定义了标准原型 (*.proto) 的位置:
此外,这个path 在 IntelliJ 中定义在 Project Structure \ Global Libraries:
代码organization.proto 导入google/protobuf/empty.proto 以使用Empty 类:
syntax = "proto3";
package auge.protobuf;
import "google/protobuf/empty.proto";
service OrganizationService {
rpc GetOrganizations (google.protobuf.Empty) returns (OrganizationsResponse) {}
}
IntelliJ 分析器识别 IDEA 上的 import "google/protobuf/empty.proto" 和 Empty 类,但 protoc 找不到。
环境是:
- 所以:Windows 7 x64
- 协议:libprotoc 3.6.1
- 飞镖:2.2.0-edge
【问题讨论】:
标签: dart protocol-buffers grpc protoc