当使用Spring Boot 2.0.0.RELEASE与google-cloud-pubsub时,Gradle碰到io.netty的版本

问题描述 投票:0回答:1

我有一个Spring Boot应用程序在最新的2.0.0.M5上运行,使用google-cloud-pubsub:0.0.28。当我将Spring提升到2.0.0时.RELEASE Spring无法启动此错误:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.netty.handler.ssl.OpenSslEngine
at io.netty.handler.ssl.OpenSslContext.newEngine0(OpenSslContext.java:49)
at io.netty.handler.ssl.ReferenceCountedOpenSslContext.newEngine(ReferenceCountedOpenSslContext.java:358)
at io.grpc.netty.ProtocolNegotiators$TlsNegotiator$1.handlerAdded(ProtocolNegotiators.java:306)
at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:617)
... 19 common frames omitted

我注意到在碰到Spring版本后,Gradle开始拉入io.netty:netty-codec-http2:4.1.22而不是4.1.16,就像它弹出的M5版本一样。

我的build.gradle

 buildscript {
    ext.kotlinVersion = '1.2.0'
    ext.springBootVersion = '2.0.0.RELEASE'
    ext.junitPlatformVersion = '1.0.2'
    ext.cucumberVersion = '2.3.1'

    repositories {
        mavenCentral()
        jcenter()
        maven { url "https://repo.spring.io/milestone" }
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.2" }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
        classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}"
        classpath "org.junit.platform:junit-platform-gradle-plugin:${junitPlatformVersion}"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

apply {
    plugin 'kotlin'
    plugin 'kotlin-spring'
    plugin 'org.springframework.boot'
    plugin "org.junit.platform.gradle.plugin"
    plugin 'io.spring.dependency-management'
}

sourceCompatibility = 1.8

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

junitPlatform {
    filters {
        engines {
            include "spek"
        }
    }
}

configurations {
    ktlint
    acceptanceCompile.extendsFrom compile
    acceptanceRuntime.extendsFrom runtime
}

repositories {
    mavenCentral()
    jcenter()
    maven { url "https://repo.spring.io/milestone" }
    maven { url "https://repo.spring.io/snapshot" }
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}"
    compile "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}"
    compile "com.google.cloud:google-cloud-pubsub:0.28.0-beta"
}

依赖树:

:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.2.0
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.0
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.0 (*)
+--- org.jetbrains.kotlin:kotlin-reflect:1.2.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.0 (*)
\--- com.google.cloud:google-cloud-pubsub:0.28.0-beta
     +--- io.netty:netty-tcnative-boringssl-static:2.0.6.Final
     +--- com.google.cloud:google-cloud-core:1.10.0
     |    +--- com.google.guava:guava:20.0
     |    +--- joda-time:joda-time:2.9.2 -> 2.9.9
     |    +--- org.json:json:20160810
     |    +--- com.google.http-client:google-http-client:1.23.0
     |    |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.0
     |    |    \--- org.apache.httpcomponents:httpclient:4.0.1 -> 4.5.5
     |    |         +--- org.apache.httpcomponents:httpcore:4.4.9
     |    |         \--- commons-codec:commons-codec:1.10 -> 1.11
     |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    +--- com.google.api:api-common:1.2.0
     |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    \--- com.google.guava:guava:19.0 -> 20.0
     |    +--- com.google.api:gax:1.14.0
     |    |    +--- com.google.auto.value:auto-value:1.2
     |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    +--- com.google.guava:guava:20.0
     |    |    +--- org.threeten:threetenbp:1.3.3
     |    |    +--- com.google.auth:google-auth-library-oauth2-http:0.9.0
     |    |    |    +--- com.google.auth:google-auth-library-credentials:0.9.0
     |    |    |    +--- com.google.http-client:google-http-client:1.19.0 -> 1.23.0 (*)
     |    |    |    +--- com.google.http-client:google-http-client-jackson2:1.19.0
     |    |    |    |    +--- com.google.http-client:google-http-client:1.19.0 -> 1.23.0 (*)
     |    |    |    |    \--- com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.9.4
     |    |    |    \--- com.google.guava:guava:19.0 -> 20.0
     |    |    \--- com.google.api:api-common:1.2.0 (*)
     |    +--- com.google.protobuf:protobuf-java-util:3.4.0
     |    |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    |    +--- com.google.guava:guava:19.0 -> 20.0
     |    |    \--- com.google.code.gson:gson:2.7 -> 2.8.2
     |    +--- com.google.api.grpc:proto-google-common-protos:1.0.0
     |    |    \--- com.google.protobuf:protobuf-java:3.3.0 -> 3.4.0
     |    \--- com.google.api.grpc:proto-google-iam-v1:0.1.24
     |         +--- com.google.protobuf:protobuf-java:3.3.0 -> 3.4.0
     |         +--- com.google.api:api-common:1.1.0 -> 1.2.0 (*)
     |         \--- com.google.api.grpc:proto-google-common-protos:1.0.0 (*)
     +--- com.google.cloud:google-cloud-core-grpc:1.10.0
     |    +--- io.netty:netty-tcnative-boringssl-static:2.0.6.Final
     |    +--- com.google.auth:google-auth-library-credentials:0.9.0
     |    +--- com.google.cloud:google-cloud-core:1.10.0 (*)
     |    +--- com.google.guava:guava:20.0
     |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    +--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
     |    +--- io.grpc:grpc-protobuf:1.7.0
     |    |    +--- io.grpc:grpc-core:1.7.0
     |    |    |    +--- io.grpc:grpc-context:1.7.0
     |    |    |    +--- com.google.guava:guava:19.0 -> 20.0
     |    |    |    +--- com.google.errorprone:error_prone_annotations:2.0.19
     |    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    |    +--- com.google.instrumentation:instrumentation-api:0.4.3
     |    |    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    |    |    \--- com.google.guava:guava:19.0 -> 20.0
     |    |    |    \--- io.opencensus:opencensus-api:0.6.0
     |    |    |         \--- com.google.guava:guava:19.0 -> 20.0
     |    |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    |    +--- com.google.guava:guava:19.0 -> 20.0
     |    |    +--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
     |    |    +--- com.google.api.grpc:proto-google-common-protos:0.1.9 -> 1.0.0 (*)
     |    |    \--- io.grpc:grpc-protobuf-lite:1.7.0
     |    |         +--- io.grpc:grpc-core:1.7.0 (*)
     |    |         \--- com.google.guava:guava:19.0 -> 20.0
     |    +--- io.grpc:grpc-context:1.7.0
     |    +--- io.grpc:grpc-netty:1.7.0
     |    |    +--- io.grpc:grpc-core:[1.7.0] -> 1.7.0 (*)
     |    |    +--- io.netty:netty-codec-http2:[4.1.16.Final] -> 4.1.22.Final
     |    |    |    +--- io.netty:netty-codec-http:4.1.22.Final
     |    |    |    |    \--- io.netty:netty-codec:4.1.22.Final
     |    |    |    |         \--- io.netty:netty-transport:4.1.22.Final
     |    |    |    |              +--- io.netty:netty-buffer:4.1.22.Final
     |    |    |    |              |    \--- io.netty:netty-common:4.1.22.Final
     |    |    |    |              \--- io.netty:netty-resolver:4.1.22.Final
     |    |    |    |                   \--- io.netty:netty-common:4.1.22.Final
     |    |    |    \--- io.netty:netty-handler:4.1.22.Final
     |    |    |         +--- io.netty:netty-buffer:4.1.22.Final (*)
     |    |    |         +--- io.netty:netty-transport:4.1.22.Final (*)
     |    |    |         \--- io.netty:netty-codec:4.1.22.Final (*)
     |    |    \--- io.netty:netty-handler-proxy:4.1.16.Final -> 4.1.22.Final
     |    |         +--- io.netty:netty-transport:4.1.22.Final (*)
     |    |         +--- io.netty:netty-codec-socks:4.1.22.Final
     |    |         |    \--- io.netty:netty-codec:4.1.22.Final (*)
     |    |         \--- io.netty:netty-codec-http:4.1.22.Final (*)
     |    +--- io.grpc:grpc-stub:1.7.0
     |    |    \--- io.grpc:grpc-core:1.7.0 (*)
     |    +--- io.grpc:grpc-auth:1.7.0
     |    |    +--- io.grpc:grpc-core:[1.7.0] -> 1.7.0 (*)
     |    |    \--- com.google.auth:google-auth-library-credentials:0.4.0 -> 0.9.0
     |    \--- com.google.api:gax-grpc:1.14.0
     |         +--- com.google.auto.value:auto-value:1.2
     |         +--- com.google.code.findbugs:jsr305:3.0.0
     |         +--- com.google.api:gax:1.14.0 (*)
     |         +--- io.grpc:grpc-netty:1.7.0 (*)
     |         +--- io.grpc:grpc-stub:1.7.0 (*)
     |         +--- io.grpc:grpc-auth:1.7.0 (*)
     |         +--- io.grpc:grpc-protobuf:1.7.0 (*)
     |         +--- com.google.guava:guava:20.0
     |         +--- org.threeten:threetenbp:1.3.3
     |         +--- com.google.auth:google-auth-library-oauth2-http:0.9.0 (*)
     |         +--- com.google.auth:google-auth-library-credentials:0.9.0
     |         +--- com.google.api.grpc:proto-google-common-protos:1.0.0 (*)
     |         \--- com.google.api:api-common:1.2.0 (*)
     +--- com.google.api.grpc:proto-google-cloud-pubsub-v1:0.1.24
     |    +--- com.google.api.grpc:proto-google-iam-v1:0.1.24 (*)
     |    +--- com.google.protobuf:protobuf-java:3.3.0 -> 3.4.0
     |    +--- com.google.api:api-common:1.1.0 -> 1.2.0 (*)
     |    \--- com.google.api.grpc:proto-google-common-protos:1.0.0 (*)
     +--- com.google.api.grpc:grpc-google-cloud-pubsub-v1:0.1.24
     |    +--- com.google.api.grpc:proto-google-cloud-pubsub-v1:0.1.24 (*)
     |    +--- io.grpc:grpc-stub:1.7.0 (*)
     |    \--- io.grpc:grpc-protobuf:1.7.0 (*)
     +--- io.grpc:grpc-netty:1.7.0 (*)
     +--- io.grpc:grpc-stub:1.7.0 (*)
     \--- io.grpc:grpc-auth:1.7.0 (*)

(*) - dependencies omitted (listed previously)

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed

我在我的build.gradle尝试了各种各样的排除。关于如何让Gradle拉入4.1.16而不是io.netty的任何想法?

spring-boot gradle google-cloud-pubsub
1个回答
0
投票

如果您可以升级使用gRPC 1.9.0的Pub / Sub客户端版本,可能会更好。或者,只需将gRPC版本升级到1.9.0。使用较新的gRPC版本,您可以排除grpc-netty依赖项并包含grpc-netty-shaded依赖项。这应避免与Spring Boot的Netty发生冲突。

我们还积极致力于开发具有Spring Boot 2功能的cloud.spring.io/spring-cloud-gcp/,它将能够引入正确的依赖关系。

© www.soinside.com 2019 - 2024. All rights reserved.