kotlin - 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 服务器的链接或知识。
对不起这个简单的问题,但这真的让我很不安,这只是行不通
解决方案
将grpc-kotlin-stub
版本替换1.1.0-SNAPSHOT
为1.1.0
; 因为在这些存储库中找不到快照。或者您应该首先通过在项目中使用安装1.1.0-SNAPSHOT
到本地 maven 存储库。mvn install
grpc-kotlin-stub
推荐阅读
- jupyter-notebook - 使图像网格框可滚动
- c - 如何存储守护进程?
- python - 在使用 Jupyter notebook 在 Sentiment Analysis 中定义 get Analysis (score) 时遇到缩进错误
- node.js - 在单个命令中运行多个 NodeJS 服务器
- ios - Firebase AppCheck 的用途是什么?
- firebase - Flutter:如何定义 Firestore 集合的模型或 Firestore 字段的数据类型?
- reactjs - .gitignore 中的 Gitlab node_modules,如何仍然编辑和推送模块
- python-3.x - 如何使用 Postman 在 DRF 中上传个人资料图片(如果可能,不创建单独的端点)
- json - 将 JSON 数据解析为列表 (Dart)
- java - 无法使用 java 11 运行 jar