gpt4 book ai didi

spring-boot - 使用Spring Boot 2.0.0.RELEASE和google-cloud-pubsub时,Gradle提升io.netty版本

转载 作者:行者123 更新时间:2023-12-03 05:47:58 26 4
gpt4 key购买 nike

我有一个运行在最新的2.0.0.M5上的Spring Boot应用程序,带有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,就像Spring 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.16io.netty而不是 4.1.22的任何想法?

最佳答案

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

我们还在积极地工作在cloud.spring.io/spring-cloud-gcp/上,它将在Spring Boot 2下运行,它将能够引入正确的依赖关系。

关于spring-boot - 使用Spring Boot 2.0.0.RELEASE和google-cloud-pubsub时,Gradle提升io.netty版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49075212/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com