"package io.grpc does not exist" 和 "static import only from classes and interfaces" 尝试生成 Java Protobuf 代码时

"package io.grpc does not exist" and "static import only from classes and interfaces" when trying to generate Java Protobuf code

我正在尝试关注此博客 post、https://redbyte.eu/en/blog/calling-java-from-go-using-grpc/, in this repository, https://github.com/khpeek/pdf-parser。在运行./gradlew build之后,项目结构如下:

.
├── build
│   ├── classes
│   │   └── java
│   │       └── main
│   ├── extracted-include-protos
│   │   └── main
│   │       └── google
│   │           └── protobuf
│   │               ├── any.proto
│   │               ├── api.proto
│   │               ├── compiler
│   │               │   └── plugin.proto
│   │               ├── descriptor.proto
│   │               ├── duration.proto
│   │               ├── empty.proto
│   │               ├── field_mask.proto
│   │               ├── source_context.proto
│   │               ├── struct.proto
│   │               ├── timestamp.proto
│   │               ├── type.proto
│   │               └── wrappers.proto
│   ├── extracted-protos
│   │   └── main
│   ├── generated
│   │   ├── source
│   │   │   └── proto
│   │   │       └── main
│   │   │           ├── grpc
│   │   │           │   └── eu
│   │   │           │       └── redbyte
│   │   │           │           └── pdfparser
│   │   │           │               └── grpc
│   │   │           │                   └── PDFParserGrpc.java
│   │   │           └── java
│   │   │               └── eu
│   │   │                   └── redbyte
│   │   │                       └── pdfparser
│   │   │                           └── grpc
│   │   │                               ├── PDFParserApi.java
│   │   │                               ├── ParserRequest.java
│   │   │                               ├── ParserRequestOrBuilder.java
│   │   │                               ├── ParserResponse.java
│   │   │                               └── ParserResponseOrBuilder.java
│   │   └── sources
│   │       ├── annotationProcessor
│   │       │   └── java
│   │       │       └── main
│   │       └── headers
│   │           └── java
│   │               └── main
│   └── tmp
│       ├── compileJava
│       │   └── source-classes-mapping.txt
│       └── jar
│           └── MANIFEST.MF
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
    └── main
        └── proto
            └── pdfparserapi.proto

40 directories, 26 files

问题是 ./gradlew build returns 以下错误:

> ./gradlew build

> Task :compileJava FAILED
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:3: error: package io.grpc does not exist
import static io.grpc.MethodDescriptor.generateFullMethodName;
                     ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:3: error: static import only from classes and interfaces
import static io.grpc.MethodDescriptor.generateFullMethodName;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:4: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:4: error: static import only from classes and interfaces
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:5: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:5: error: static import only from classes and interfaces
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:6: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:6: error: static import only from classes and interfaces
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:7: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:7: error: static import only from classes and interfaces
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:8: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:8: error: static import only from classes and interfaces
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:9: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:9: error: static import only from classes and interfaces
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:10: error: package io.grpc.stub does not exist
import static io.grpc.stub.ClientCalls.futureUnaryCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:10: error: static import only from classes and interfaces
import static io.grpc.stub.ClientCalls.futureUnaryCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:11: error: package io.grpc.stub does not exist
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:11: error: static import only from classes and interfaces
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:12: error: package io.grpc.stub does not exist
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:12: error: static import only from classes and interfaces
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:13: error: package io.grpc.stub does not exist
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:13: error: static import only from classes and interfaces
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:14: error: package io.grpc.stub does not exist
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:14: error: static import only from classes and interfaces
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:15: error: package io.grpc.stub does not exist
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:15: error: static import only from classes and interfaces
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:16: error: package io.grpc.stub does not exist
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
                          ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:16: error: static import only from classes and interfaces
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:20: error: cannot find symbol
@javax.annotation.Generated(
                 ^
  symbol:   class Generated
  location: package javax.annotation
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:30: error: package io.grpc does not exist
  private static volatile io.grpc.MethodDescriptor<eu.redbyte.pdfparser.grpc.ParserRequest,
                                 ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:38: error: package io.grpc does not exist
  public static io.grpc.MethodDescriptor<eu.redbyte.pdfparser.grpc.ParserRequest,
                       ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:65: error: package io.grpc does not exist
  public static PDFParserStub newStub(io.grpc.Channel channel) {
                                             ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:111: error: package io.grpc.stub does not exist
  public static final class PDFParserStub extends io.grpc.stub.AbstractStub<PDFParserStub> {
                                                              ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:73: error: package io.grpc does not exist
      io.grpc.Channel channel) {
             ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:138: error: package io.grpc.stub does not exist
  public static final class PDFParserBlockingStub extends io.grpc.stub.AbstractStub<PDFParserBlockingStub> {
                                                                      ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:81: error: package io.grpc does not exist
      io.grpc.Channel channel) {
             ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:164: error: package io.grpc.stub does not exist
  public static final class PDFParserFutureStub extends io.grpc.stub.AbstractStub<PDFParserFutureStub> {
                                                                    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:263: error: package io.grpc does not exist
  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
                                 ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:265: error: package io.grpc does not exist
  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
                       ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:165: error: package io.grpc does not exist
    private PDFParserFutureStub(io.grpc.Channel channel) {
                                       ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:169: error: package io.grpc does not exist
    private PDFParserFutureStub(io.grpc.Channel channel,
                                       ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:170: error: package io.grpc does not exist
        io.grpc.CallOptions callOptions) {
               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:175: error: package io.grpc does not exist
    protected PDFParserFutureStub build(io.grpc.Channel channel,
                                               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:176: error: package io.grpc does not exist
        io.grpc.CallOptions callOptions) {
               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:139: error: package io.grpc does not exist
    private PDFParserBlockingStub(io.grpc.Channel channel) {
                                         ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:143: error: package io.grpc does not exist
    private PDFParserBlockingStub(io.grpc.Channel channel,
                                         ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:144: error: package io.grpc does not exist
        io.grpc.CallOptions callOptions) {
               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:149: error: package io.grpc does not exist
    protected PDFParserBlockingStub build(io.grpc.Channel channel,
                                                 ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:150: error: package io.grpc does not exist
        io.grpc.CallOptions callOptions) {
               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:112: error: package io.grpc does not exist
    private PDFParserStub(io.grpc.Channel channel) {
                                 ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:116: error: package io.grpc does not exist
    private PDFParserStub(io.grpc.Channel channel,
                                 ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:117: error: package io.grpc does not exist
        io.grpc.CallOptions callOptions) {
               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:122: error: package io.grpc does not exist
    protected PDFParserStub build(io.grpc.Channel channel,
                                         ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:123: error: package io.grpc does not exist
        io.grpc.CallOptions callOptions) {
               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:130: error: package io.grpc.stub does not exist
        io.grpc.stub.StreamObserver<eu.redbyte.pdfparser.grpc.ParserResponse> responseObserver) {
                    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:87: error: package io.grpc does not exist
  public static abstract class PDFParserImplBase implements io.grpc.BindableService {
                                                                   ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:92: error: package io.grpc.stub does not exist
        io.grpc.stub.StreamObserver<eu.redbyte.pdfparser.grpc.ParserResponse> responseObserver) {
                    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:96: error: package io.grpc does not exist
    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
                                            ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:192: error: package io.grpc.stub.ServerCalls does not exist
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
                              ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:193: error: package io.grpc.stub.ServerCalls does not exist
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
                              ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:194: error: package io.grpc.stub.ServerCalls does not exist
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
                              ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:195: error: package io.grpc.stub.ServerCalls does not exist
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
                              ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:206: error: package io.grpc.stub does not exist
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
                                                ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:220: error: package io.grpc.stub does not exist
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
                    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:219: error: package io.grpc.stub does not exist
    public io.grpc.stub.StreamObserver<Req> invoke(
                       ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:229: error: package io.grpc.protobuf does not exist
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
                                 ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:229: error: package io.grpc.protobuf does not exist
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
                                                                               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:250: error: package io.grpc.protobuf does not exist
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
                                 ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:33: error: package io.grpc.stub.annotations does not exist
  @io.grpc.stub.annotations.RpcMethod(
                           ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:37: error: package io.grpc.MethodDescriptor does not exist
      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
                                           ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:40: error: package io.grpc does not exist
    io.grpc.MethodDescriptor<eu.redbyte.pdfparser.grpc.ParserRequest, eu.redbyte.pdfparser.grpc.ParserResponse> getParseMethod;
           ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:46: error: package io.grpc.MethodDescriptor does not exist
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
                                               ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:45: error: package io.grpc does not exist
              io.grpc.MethodDescriptor.<eu.redbyte.pdfparser.grpc.ParserRequest, eu.redbyte.pdfparser.grpc.ParserResponse>newBuilder()
                     ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:47: error: cannot find symbol
              .setFullMethodName(generateFullMethodName(
                                 ^
  symbol:   method generateFullMethodName(String,String)
  location: class PDFParserGrpc
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:50: error: package io.grpc.protobuf does not exist
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                                                    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:52: error: package io.grpc.protobuf does not exist
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                                                     ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:96: error: method does not override or implement a method from a supertype
    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:97: error: package io.grpc does not exist
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
                    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:100: error: cannot find symbol
            asyncUnaryCall(
            ^
  symbol:   method asyncUnaryCall(MethodHandlers<ParserRequest,ParserResponse>)
  location: class PDFParserImplBase
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:121: error: method does not override or implement a method from a supertype
    @java.lang.Override
    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:132: error: cannot find symbol
          getChannel().newCall(getParseMethod(), getCallOptions()), request, responseObserver);
          ^
  symbol:   method getChannel()
  location: class PDFParserStub
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:132: error: cannot find symbol
          getChannel().newCall(getParseMethod(), getCallOptions()), request, responseObserver);
                                                 ^
  symbol:   method getCallOptions()
  location: class PDFParserStub
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:148: error: method does not override or implement a method from a supertype
    @java.lang.Override
    ^
                           ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:217: error: method does not override or implement a method from a supertype
    @java.lang.Override
    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:232: error: method does not override or implement a method from a supertype
    @java.lang.Override
    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:237: error: method does not override or implement a method from a supertype
    @java.lang.Override
    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:257: error: method does not override or implement a method from a supertype
    @java.lang.Override
    ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:266: error: package io.grpc does not exist
    io.grpc.ServiceDescriptor result = serviceDescriptor;
           ^
/Users/kurtpeek/go/src/github.com/kurtpeek/pdf-parser/build/generated/source/proto/main/grpc/eu/redbyte/pdfparser/grpc/PDFParserGrpc.java:271: error: package io.grpc does not exist
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
                                              ^
96 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 810ms
4 actionable tasks: 1 executed, 3 up-to-date

我尝试将以下行添加到 build.gradle

中的 dependencies
    compile group: 'io.grpc', name: 'protoc-gen-grpc-java', version: '1.14.0'

但这导致了同样的错误。关于如何修复 Gradle 构建的任何想法?

io.grpc.*grpc-api 中(大多数其他 grpc 依赖项将依赖于此)。 io.grpc.stub.*grpc-stub 中。 io.grpc.protobuf.*grpc-protobuf 中。 javax.annotation.Generated 可以在 Tomcat 的 annotations-api 中找到。

所以需要添加(如grpc-java readme中所述):

implementation "io.grpc:grpc-protobuf:1.14.0"
implementation "io.grpc:grpc-stub:1.14.0"
compileOnly "org.apache.tomcat:annotations-api:6.0.53"

gRPC v1.14.0 已经很老了;您应该升级到较新的版本以供实际使用。要真正 运行,您可能还需要 implementation 'io.grpc:grpc-netty-shaded:1.34.1'