java - 构建项目缺少依赖项后生成的 ProtoBuffer 文件
问题描述
我正在尝试在 grpc 的帮助下创建实现客户端-服务器通信
原型文件 -
syntax="proto3";
package com.project.grpc.roleservice;
message UserRequest {
string userName=1;
}
message RoleReply {
string userRole=1;
}
service UserRoleFromServer{
rpc getRoleUser(stream UserRequest) returns (stream RoleReply);
}
摇篮构建 -
buildscript {
ext {
springBootVersion = '2.0.4.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("com.google.protobuf:protobuf-gradle-plugin:0.8.5")
}
}
plugins {
id 'java'
}
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.google.protobuf'
group 'com.project.grpc.roleservice'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.5.1-1"
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.16.1'
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
compile( 'io.grpc:grpc-netty-shaded:1.16.1')
compile('io.grpc:grpc-protobuf:1.16.1')
compile('io.grpc:grpc-stub:1.16.1')
compile 'io.github.lognet:grpc-spring-boot-starter:3.0.0'
runtime('org.springframework.boot:spring-boot-devtools')
runtime('mysql:mysql-connector-java')
testCompile (group: 'junit', name: 'junit', version: '4.12')
}
构建项目后,所有文件都在构建文件夹中生成,并生成了一个 UserRoleFromServerGrpc,我想在我的服务器服务文件中扩展和实现它
但是 UserRoleFromServerGrpc 有很多错误,它要求以下依赖项
Streamobserver 需要 io.grpc:grpc-stub:1.16.1 ,grpc-core
将 io.grpc:grpc-stub:1.16.1 添加到类路径
但我已经在 gradle build 中定义了这些依赖项
如何解决此问题
IDE 截图
解决方案
推荐阅读
- javascript - 为什么这个“if”语句放置有效
- postgresql - 无法从 pgadmin、CLI 连接到 IBM PostgreSQL
- azure-devops - 在 Azure DevOps 中导入工作项 .csv 文件时出错
- python-3.x - 2d python 列表populaiton
- android - Flutter json数组解析
- reactjs - 我从 apollo 客户端的突变怎么会得到 400 错误,而我可以在操场上做到这一点?
- javascript - 将 Promise.all 与 Promise 数组一起使用
- nginx - 页面数据刷新不一致
- php - 如何合并 3 个数组、分组和计算重复项?
- python - 当 AWS::CustomResource 具有列表类型输出时如何获取选择性项目