构建项目缺少依赖项后生成的ProtoBuffer文件

时间:2018-10-31 16:48:03

标签: java spring-boot protocol-buffers grpc

我正在尝试借助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);
}

Gradle版本-

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的屏幕截图

enter image description here

0 个答案:

没有答案
相关问题