我只是遇到了一个问题,在这个问题中,对ProtocolStringListprot 的引用生成的代码内部引发了一个类未找到错误.
在这种情况下,我收到了一个Eclipse错误:
com.google.protobuf.ProtocolStringList cannot be resolved to a type
Run Code Online (Sandbox Code Playgroud)
我希望它也可以显示为:
java.lang.NoClassDefFoundError: com/google/protobuf/ProtocolStringList
Run Code Online (Sandbox Code Playgroud) 这似乎是一个以前被问过好几次的问题,但我找到的答案都不够明确,而且似乎都遗漏了一步。我想在我的Windows系统中使用protocol buffer编译器。因此,我下载了 Python 的最新版本https://github.com/protocolbuffers/protobuf/releases/tag/v3.8.0
在 zip 中,您可以找到第一个 README,其中写着“ Protobuf 支持多种不同的编程语言。对于每种编程语言,您可以在相应的源目录中找到有关如何为该特定语言安装 protobuf 运行时的说明”。
因此,我转到“Python”文件夹并打开第二个自述文件,其中包含以下内容:
1) 确保您有 Python 2.7 或更高版本。如果有疑问,请运行:
$ python -V
2) 如果您没有安装setuptools,请注意,一旦您运行setup.py[...],它将自动下载并安装。
3) 构建 C++ 代码,或安装protoc. 如果您安装二进制构建 C++ 代码发行版,请确保它与此包的版本相同。如果有疑问,请运行:
$ 协议--版本
我的问题是,我应该如何安装 的二进制发行版protoc?这个二进制发行版在哪里?我需要做什么来安装它?zip 文件中包含的许多其他文件夹之一中是否有相关说明?哪一个 ?我可以看到还有许多其他自述文件,但我担心随机遵循所有这些说明而不确定我在做什么的想法。
到目前为止,我发现的所有答案都晦涩难懂,或者重新将您发送到开头(例如:protoc 在哪里以及如何安装它?)
如何获取与协议缓冲区字段相关的选项?
假设我有一个带有自定义选项的字段,例如:
syntax = "proto3";
package main;
import "google/protobuf/descriptor.proto";
extend google.protobuf.FieldOptions {
bool required = 7000;
}
message Person {
string name = 1 [(required) = true];
}
Run Code Online (Sandbox Code Playgroud)
生成了 js 文件protoc
syntax = "proto3";
package main;
import "google/protobuf/descriptor.proto";
extend google.protobuf.FieldOptions {
bool required = 7000;
}
message Person {
string name = 1 [(required) = true];
}
Run Code Online (Sandbox Code Playgroud)
我已经阅读了如何从此处检索其他语言的选项,但似乎可以在 Javascript 中进行任何操作。
任何帮助将不胜感激!
我想使用 protoc-gen-grpc-kotlin 中的protoc-gen-grpc-kotlin -1.0.0并且我得到了
\nExecution failed for task \':generateProto\'.\n> Could not resolve all files for configuration \':protobufToolsLocator_grpckt\'.\n > Could not find protoc-gen-grpc-kotlin-1.0.0-windows-x86_64.exe (io.grpc:protoc-gen-grpc-kotlin:1.0.0).\n Searched in the following locations:\n https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-kotlin/1.0.0/protoc-gen-grpc-kotlin-1.0.0-windows-x86_64.exe\n\nPossible solution:\n - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html\nRun Code Online (Sandbox Code Playgroud)\n整个堆栈跟踪是
\nC:\\_d\\toLearn\\demo-grpc-jaeger>gradle clean build --stacktrace\n> Task :generateProto FAILED\n\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nExecution failed for task \':generateProto\'.\n> Could not resolve all files for configuration \':protobufToolsLocator_grpckt\'.\n > Could not find protoc-gen-grpc-kotlin-1.0.0-windows-x86_64.exe (io.grpc:protoc-gen-grpc-kotlin:1.0.0).\n Searched …Run Code Online (Sandbox Code Playgroud) 这是.proto我使用的文件:
pkg/apis/workflow/v1alpha1/ generated.proto
syntax = 'proto2';
package go-server.com.argo-new.pkg.apis.workflow.v1alpha1;
import "k8s.io/api/core/v1/generated.proto";
import "k8s.io/api/policy/v1beta1/generated.proto";
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
// Package-wide variables from generator "generated".
option go_package = "v1alpha1";
// ArchiveStrategy describes how to archive files/directory when saving artifacts
message ArchiveStrategy {
optional TarStrategy tar = 1;
optional NoneStrategy none = 2;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译时:
protoc -I /usr/local/include -I . -I ./vendor -I /root/go/src \
-I /root/go/pkg/mod/github.com/gogo/protobuf@v1.3.1/gogoproto \
-I /root/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.12.2/third_party/googleapis \
--include_imports --gogofast_out=plugins=grpc:/root/go/src \
--grpc-gateway_out=logtostderr=true:/root/go/src \
--swagger_out=logtostderr=true,fqn_for_swagger_name=true:. \
pkg/apis/workflow/v1alpha1/generated.proto
Run Code Online (Sandbox Code Playgroud)
它提醒我: …
我试图制作一个连接到数据库并获取信息并通过 grpc 将它们输出到桌面应用程序的项目。但是,当我编译它时,我在目标文件(由 protoc 自动生成)中得到“错误:(20,18)java:找不到符号”。我无法理解这个问题。我试图改变mvn 的编译器,更改 protoc 上的版本,设置不同的 JDK,一切都变得更糟了。
我的项目可以在这里查看:https : //github.com/Diana-Ioana/grpc 我的数据库和崩溃的生成目标文件的错误是:https : //imgur.com/a/T6taLXF
我不知道现在该怎么办。任何帮助都会很棒,谢谢!
我试图使用以下插件构建 grpc 服务。似乎该插件无法使用 protoc 实用程序。
操作系统:MAC
Maven版本:3.6.3
错误 :
[ERROR] PROTOC FAILED: google/protobuf/wrappers.proto: File not found.
order-mgmt.proto: Import "google/protobuf/wrappers.proto" was not found or had errors.
order-mgmt.proto:7:16: "google.protobuf.StringValue" is not defined.
...
**[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile (default) on project OrderManagement-gRPC: protoc did not exit cleanly. Review output for more information. -> [Help 1]**
Run Code Online (Sandbox Code Playgroud)
我正在使用的插件是:
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> </configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
Run Code Online (Sandbox Code Playgroud) 我第一次在 Go 中使用 protobuf(和 protoc)。
message MyProtoStruct {
string description = 1;
}
Run Code Online (Sandbox Code Playgroud)
我有点困惑:
我应该使用方法来获取值(如MyProtoStruct.GetDescription())还是
我应该直接使用字段(如MyProtoStruct.Description)吗?