簡體   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