gpt4 book ai didi

java - 使用多模块 Maven 应用程序编译 grpc

转载 作者:行者123 更新时间:2023-11-30 05:31:34 24 4
gpt4 key购买 nike

我的架构如下。

两台服务器

moduleA/src/main/resources/fileA.proto

moduleB/src/main/resources/fileB.proto

客户端(面向服务器端点的浏览器调用两个服务器之上)

service/src/main

问题:我的 moduleA 中有以下 POM,但它没有生成 stub 。

<dependencies>
<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.15.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.15.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.15.1</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.9.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.22.1:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

最佳答案

原型(prototype)文件位置应为src/main/proto/。另外,protobuf 的版本似乎不匹配。在依赖关系中,protobuf 版本是 3.6.1,其中 protoc 插件使用的是 3.9.0。

关于java - 使用多模块 Maven 应用程序编译 grpc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57417269/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com