首页 > 解决方案 > Kotlin/JVM 上的 Grpc

问题描述

我一直在寻找一个博客左右,它解释了如何将 grpc 添加到我的项目中。我发现的最好的是:https ://medium.com/swlh/using-grpc-with-kotlin-for-building-microservices-2a79d95a236a

不幸的是,这里的步骤没有清楚地解释。例如。proto 文件应该在哪里定位,我应该在哪里准确导入 Protobuf 编译器(我真正需要什么?)。错误:任务 ':stub:extractIncludeProto' 执行失败。

> Could not resolve all files for configuration ':stub:compileProtoPath'.
   > Could not find io.grpc:grpc-kotlin-stub:1.1.0-SNAPSHOT.
     Searched in the following locations:
       - file:/C:/Users/David/.m2/repository/io/grpc/grpc-kotlin-stub/1.1.0-SNAPSHOT/maven-metadata.xml
       - file:/C:/Users/David/.m2/repository/io/grpc/grpc-kotlin-stub/1.1.0-SNAPSHOT/grpc-kotlin-stub-1.1.0-SNAPSHOT.pom
       - https://repo.maven.apache.org/maven2/io/grpc/grpc-kotlin-stub/1.1.0-SNAPSHOT/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/io/grpc/grpc-kotlin-stub/1.1.0-SNAPSHOT/grpc-kotlin-stub-1.1.0-SNAPSHOT.pom
       - https://dl.google.com/dl/android/maven2/io/grpc/grpc-kotlin-stub/1.1.0-SNAPSHOT/maven-metadata.xml
       - https://dl.google.com/dl/android/maven2/io/grpc/grpc-kotlin-stub/1.1.0-SNAPSHOT/grpc-kotlin-stub-1.1.0-SNAPSHOT.pom
     Required by:
         project :stub

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

基本问题可能是所有grpc 教程都基于这个github 存储库,我无法从示例文件夹中编译任何项目。问题是 gradle 找不到原始项目,即使它在那里(在我看来)。

所以我决定问你,如果有人有关于如何使用空 Kotlin/JVM 应用程序的基础制作简单 grpc 服务器的链接或知识。

对不起这个简单的问题,但这真的让我很不安,这只是行不通

标签: kotlinintellij-ideajvmgrpc

解决方案


grpc-kotlin-stub版本替换1.1.0-SNAPSHOT1.1.0; 因为在这些存储库中找不到快照。或者您应该首先通过在项目中使用安装1.1.0-SNAPSHOT到本地 maven 存储库。mvn installgrpc-kotlin-stub


推荐阅读