protoc-jar-maven-plugin:不生成grpc服务存根

我已经添加了如下Maven配置。


        <plugin>

              <groupId>com.github.os72</groupId>

              <artifactId>protoc-jar-maven-plugin</artifactId>

              <version>3.5.1</version>

              <executions>

                  <execution>

                      <phase>generate-sources</phase>

                      <goals>

                          <goal>run</goal>

                      </goals>

                      <configuration>

                          <protocArtifact>com.google.protobuf:protoc:3.0.0</protocArtifact>

                          <inputDirectories>

                              <include>src/main/protobuf</include>

                          </inputDirectories>

                         <outputTargets>

                              <outputTarget>

                                  <type>java</type>

                                  <outputDirectory>src/main/java</outputDirectory>

                              </outputTarget>

                              <outputTarget>

                                  <type>grpc-java</type>

                                  <outputDirectory>src/main/java</outputDirectory>

                                  <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1</pluginArtifact>

                              </outputTarget>

                          </outputTargets>

                      </configuration>

                  </execution>

              </executions>

       </plugin>

我通过“ mvn protoc-jar:run”执行它,但是它跳过了grpc服务存根,只将“消息”隐蔽到Java代码中。

我只输出生成为HelloReply,HelloReplyOrBuilder,HelloRequest,HelloRequestOrBuilder,HelloWorldProto的文件。缺少Greeter Grpc服务存根。我是Maven的新手,我错过了什么。


哔哔one
浏览 475回答 2
2回答

阿晨1998

&nbsp;<plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.xolstice.maven.plugins</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>protobuf-maven-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>0.5.1</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <pluginId>grpc-java</pluginId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.4.0:exe:${os.detected.classifier}</pluginArtifact>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>protobuf-generate</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>process-resources</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>compile</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>compile-custom</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </executions>&nbsp; &nbsp; &nbsp; &nbsp; </plugin>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java