GRPC / Proto - @io.grpc.ExperimentalApi 缺少默认值
GRPC / Proto - @io.grpc.ExperimentalApi is missing a default value
我正在尝试了解 gRPC。这是我的 pom 文件。
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.9.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.22.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.22.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.22.1</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.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>
com.google.protobuf:protoc:3.0.0-beta-2:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>
io.grpc:protoc-gen-grpc-java:0.14.0:exe:${os.detected.classifier}
</pluginArtifact>
<protoSourceRoot>
${basedir}/src/main/proto
</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我总是收到编译错误 annotation @io.grpc.ExperimentalApi is missing a default value for the element 'value'
。
源码是这样生成的
public static interface DummyService {
}
@io.grpc.ExperimentalApi
public static abstract class AbstractDummyService implements DummyService, io.grpc.BindableService {
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
return DummyServiceGrpc.bindService(this);
}
}
如何解决这个问题?
protobuf-maven-plugin
配置为使用 io.grpc:protoc-gen-grpc-java:0.14.0:exe:${os.detected.classifier}
。 0.14.0 是 ancient 和 pre-1.0。我建议使用与其他 io.grpc
依赖项相同的 protoc-gen-grpc-java
版本,在本例中为 1.22.1.
因此您应该将 pluginArtifact
部分更改为:
<pluginArtifact>
io.grpc:protoc-gen-grpc-java:1.22.1:exe:${os.detected.classifier}
</pluginArtifact>
我正在尝试了解 gRPC。这是我的 pom 文件。
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.9.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.22.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.22.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.22.1</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.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>
com.google.protobuf:protoc:3.0.0-beta-2:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>
io.grpc:protoc-gen-grpc-java:0.14.0:exe:${os.detected.classifier}
</pluginArtifact>
<protoSourceRoot>
${basedir}/src/main/proto
</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我总是收到编译错误 annotation @io.grpc.ExperimentalApi is missing a default value for the element 'value'
。
源码是这样生成的
public static interface DummyService {
}
@io.grpc.ExperimentalApi
public static abstract class AbstractDummyService implements DummyService, io.grpc.BindableService {
@java.lang.Override public io.grpc.ServerServiceDefinition bindService() {
return DummyServiceGrpc.bindService(this);
}
}
如何解决这个问题?
protobuf-maven-plugin
配置为使用 io.grpc:protoc-gen-grpc-java:0.14.0:exe:${os.detected.classifier}
。 0.14.0 是 ancient 和 pre-1.0。我建议使用与其他 io.grpc
依赖项相同的 protoc-gen-grpc-java
版本,在本例中为 1.22.1.
因此您应该将 pluginArtifact
部分更改为:
<pluginArtifact>
io.grpc:protoc-gen-grpc-java:1.22.1:exe:${os.detected.classifier}
</pluginArtifact>