gpt4 book ai didi

java - 导入 "google/protobuf/timestamp.proto"未找到或有错误

转载 作者:行者123 更新时间:2023-12-02 19:22:20 26 4
gpt4 key购买 nike

我正在尝试使用时间戳并将其导入到 protobuf 消息中 -

import "google/protobuf/timestamp.proto";

message TriggerDataMsg {
google.protobuf.Timestamp start_time = 1;
google.protobuf.Timestamp end_time = 2;
google.protobuf.Timestamp next_fire_time = 3;
google.protobuf.Timestamp previous_fire_time = 4;
sint32 priority = 13;
}

当尝试使用 protoc 编译器编译生成 Java 类时,失败并出现以下错误 -

 [echo] compiling proto sources...
[exec] google/protobuf/timestamp.proto:35:8: Option "csharp_namespace" unknown.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:24:5: "google.protobuf.Timestamp" is not defined.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:25:5: "google.protobuf.Timestamp" is not defined.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:26:5: "google.protobuf.Timestamp" is not defined.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:27:5: "google.protobuf.Timestamp" is not defined.

我不确定为什么它会检查“csharp_namespace”,即使我正在生成 Java 类。我可以尝试消除此错误的任何解决方法吗?

最佳答案

如果您希望 protoc 自动导入某些内容,则它需要位于 protoc 二进制文件旁边的/include 文件夹中。

Reference

If I remember correctly, protoc looks for includes relative to the protoc binary. So if protoc is in /usr/local/bin, then it will look in /usr/local/include.

这非常适合我在 Windows 上解决:

Import "google/protobuf/wrappers.proto" was not found or had errors.

关于java - 导入 "google/protobuf/timestamp.proto"未找到或有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62874455/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com