Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java protoc编译器不使用grpc插件_Java_Maven_Protocol Buffers_Grpc - Fatal编程技术网

Java protoc编译器不使用grpc插件

Java protoc编译器不使用grpc插件,java,maven,protocol-buffers,grpc,Java,Maven,Protocol Buffers,Grpc,因此,我试图在上学习教程,但在使用带有protoc编译器的grpc插件进行编译时遇到了问题。我已经用插件正确地设置了pom.xml(我想),但是编译器没有生成指南需要的文件(即RouteGuideGrpc.java) 我目前正在使用“mvn protobuf:compile”编译.proto pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSch

因此,我试图在上学习教程,但在使用带有protoc编译器的grpc插件进行编译时遇到了问题。我已经用插件正确地设置了pom.xml(我想),但是编译器没有生成指南需要的文件(即RouteGuideGrpc.java)

我目前正在使用“mvn protobuf:compile”编译.proto

pom.xml:

<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>com.example</groupId>
<artifactId>maven</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
    <!-- https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java -->
    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>3.6.1</version>
    </dependency>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-netty-shaded</artifactId>
        <version>1.14.0</version>
    </dependency>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-protobuf</artifactId>
        <version>1.14.0</version>
    </dependency>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-stub</artifactId>
        <version>1.14.0</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.xolstice.maven.plugins</groupId>
            <artifactId>protobuf-maven-plugin</artifactId>
            <version>0.5.1</version>
            <configuration>
                <protocArtifact>com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}</protocArtifact>
                <pluginId>grpc-java</pluginId>
                <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.14.0:exe:${os.detected.classifier}</pluginArtifact>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>compile-custom</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

4.0.0
com.example
专家
0.0.1-快照
com.google.protobuf
protobuf java
3.6.1
io.grpc
网状阴影
1.14.0
io.grpc
grpc协议
1.14.0
io.grpc
grpc存根
1.14.0
马文
os maven插件
1.5.0.1最终版本
org.xolstice.maven.plugins
protobuf maven插件
0.5.1
protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}
GRPCJava
io.grpc:protoc gen grpc java:1.14.0:exe:${os.detected.classifier}
编译
编译自定义

有人知道为什么会发生这种情况,或者如何将grpc插件添加到protobuf编译器中吗?我没有正确安装插件吗


顺便说一句:我是一个使用maven的高手。

你的配置看起来是正确的。但是,
protobuf:compile
不运行任何protoc插件(包括gRPC插件);这就是
protobuf:compilecustom
所做的

因此,您只需运行:

mvn protobuf:compile-custom
输出将放在
target/generated sources/protobuf/grpc java/
文件夹中