【问题标题】:Where to set the path to the protoc to import standards Protocol Buffers在哪里设置 protoc 的路径以导入标准 Protocol Buffers
【发布时间】:2019-07-11 05:24:45
【问题描述】:

我需要在哪里将path 设置为protoc 以获取导入标准协议缓冲区(protobuf),例如Windows 和Dart 中的empty.prototimestamp.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


    【解决方案1】:

    假设你有/some/path/to/google/protobuf/empty.proto,你需要传递--proto_path=/some/path/to/这样protoc才能找到它。

    【讨论】:

      猜你喜欢
      • 2011-09-05
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 2017-02-23
      • 2010-12-09
      • 1970-01-01
      相关资源
      最近更新 更多