繁体   English   中英

Spring Data MongoDB 与 Mongo Atlas 的连接抛出“未发送 SNI 名称,请确保使用 MongoDB 3.4+ 驱动程序/shell”错误

[英]Spring Data MongoDB connection to Mongo Atlas throws 'no SNI name sent, make sure using a MongoDB 3.4+ driver/shell' error

我开始了一个全新的 Kotlin + Spring Boot 项目。 在这里,我很想通过 Spring Data MongoDB 连接到我的 Mongo Atlas 集群。

我通过application.properties设置了非常简单的配置(定义了占位符):

spring.data.mongodb.uri=mongodb+srv://backend:<password>@my-cluster.kluqx.gcp.mongodb.net/<db_name>?retryWrites=true&w=majority&authSource=admin

问题:

应用程序启动时抛出以下异常:

Caused by: com.mongodb.MongoCommandException: Command failed with error 8000 (AtlasError): 'no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.' on server my-cluster-shard-00-02.kluqx.gcp.mongodb.net:27017. The full response is {"ok": 0, "errmsg": "no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.", "code": 8000, "codeName": "AtlasError"}
at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175) ~[mongodb-driver-core-4.0.5.jar:na]
...

到目前为止我的尝试:

这些是我对这个任务的依赖:

// shortened to the relevant parts
plugins {
    id("org.jlleitschuh.gradle.ktlint") version "9.3.0"
    id("org.springframework.boot") version "2.3.3.RELEASE"
    id("io.spring.dependency-management") version "1.0.10.RELEASE"
    kotlin("jvm") version "1.3.72"
    kotlin("plugin.spring") version "1.3.72"
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
    implementation("com.graphql-java:graphql-spring-boot-starter:5.0.2")
    implementation("com.graphql-java:graphql-java-tools:5.2.4")
    developmentOnly("org.springframework.boot:spring-boot-devtools")
    annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
    }
    testImplementation("de.flapdoodle.embed:de.flapdoodle.embed.mongo")
    testImplementation("io.projectreactor:reactor-test")
}

java.sourceCompatibility = JavaVersion.VERSION_1_8

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}

编辑 1 :根据 Gradle,我的驱动程序如下:

org.mongodb:mongodb-driver-core:4.0.5
org.mongodb:mongodb-driver-sync:4.0.5

您还可以在上面提到的异常中看到, ~[mongodb-driver-core-4.0.5.jar:na]~[mongodb-driver-core-4.0.5.jar:na]

问题确实出在 JDK 上。 我在每个地方都将其更改为 14!

  • 项目结构模块和项目
  • 摇篮
  • build.gradle 文件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM