Java GRPC&x2B;Maven:无法使用'oneof':缺少符号'InternalOneOfEnum'

Java GRPC&x2B;Maven:无法使用'oneof':缺少符号'InternalOneOfEnum',java,maven,grpc,grpc-java,Java,Maven,Grpc,Grpc Java,我无法使用最新版本的GRPC编译任何包含oneof字段的GRPC消息 mvn安装导致编译错误: [ERROR] /home/travis/build/joaomlneto/grpc-java-oneof/target/generated-sources/protobuf/java/MyServiceOuterClass.java:[138,48] cannot find symbol symbol: class InternalOneOfEnum location: class co

我无法使用最新版本的GRPC编译任何包含
oneof
字段的GRPC消息

mvn安装
导致编译错误:

[ERROR] /home/travis/build/joaomlneto/grpc-java-oneof/target/generated-sources/protobuf/java/MyServiceOuterClass.java:[138,48] cannot find symbol
  symbol:   class InternalOneOfEnum
  location: class com.google.protobuf.AbstractMessage
我已经把它简化为一个两个文件的示例,但我仍然对它感到困惑。我错过了什么-(


最小、完整和可验证的示例
src/main/proto/MyService.proto
pom.xml

4.0.0
io.github.joaomlneto
测试之一
1.0-快照
罐子
UTF-8
11
11
io.grpc
网状阴影
1.24.0
io.grpc
grpc协议
1.24.0
io.grpc
grpc存根
1.24.0
javax.annotation
javax.annotation-api
1.3.2
马文
os maven插件
1.6.2
maven依赖插件
org.xolstice.maven.plugins
protobuf maven插件
0.6.1
protobuf:protoc:3.10.0:exe:${os.detected.classifier}
GRPCJava
io.grpc:protoc gen grpc java:1.24.0:exe:${os.detected.classifier}
编译
编译自定义

io.grpc:grpc protobuf:1.24.0
仍然使用
com.google.protobuf:protobuf java:3.9.0
,因此将
com.google.protobuf:3.10.0:exe降级到
3.9.0
版本将解决您的问题。

这是正确的!更多信息可以在这里找到:
syntax = "proto3";

service MyService {
  rpc uploadStuff(stream UploadStuffRequest) returns (UploadStuffResponse);
}

message UploadStuffRequest {
  oneof contents {
    string data = 1;
    string metadata = 2;
  }
}

message UploadStuffResponse {
  int32 result = 1;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>io.github.joaomlneto</groupId>
    <artifactId>oneof-test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
            <version>1.24.0</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
            <version>1.24.0</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
            <version>1.24.0</version>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>

    <build>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.6.2</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:3.10.0:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.24.0:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>



</project>