bindableService issue with grpc-java

后端 未结 2 953
故里飘歌
故里飘歌 2021-01-28 06:13

I am trying to use grpc-java v1.1.2 (build.gradle section below) but when I try to run the fat jar for the sample application, its throwing the exception given below. I do not s

相关标签:
2条回答
  • 2021-01-28 06:34

    The issue for me was, jar did not contain the dependent lib classes. I had to make this change to resolve it :

    jar {
        ...
        from {
            configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
        }
    }
    

    Which is just another way to create fat jar :)

    0 讨论(0)
  • 2021-01-28 06:46

    I fixed the issue by using the shadow plugin for creating fat jars.

        buildscript {
            repositories {
                mavenCentral()
                mavenLocal()
            }
            dependencies {
                classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.9"
                classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
                classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
            }
        }
    
        plugins {
            id 'java'
            id 'application'
            id 'idea'
            id 'com.github.johnrengelman.shadow' version '1.2.4'
            id "net.ltgt.errorprone" version '0.0.9'
        }
    
    
        shadowJar {
            baseName = 'shadow'
            classifier = null
            version = null
        }
    
    jar {
        manifest {
            attributes(
                    'Class-Path': configurations.runtime.files.collect {"$it.name"}.join(' '),
                    'Main-Class': 'com.abc.test'
            )
        }
    }
    

    Run the following:

    gradle shadowJar
    

    the shadowJar file gets created in the build/libs directory which can be run as:

    java -jar shadowJar
    
    0 讨论(0)
提交回复
热议问题