Java Spring数据MongoDB到Mongo Atlas的连接抛出';未发送SNI名称,请确保使用MongoDB 3.4+;驱动程序/外壳';错误

Java Spring数据MongoDB到Mongo Atlas的连接抛出';未发送SNI名称,请确保使用MongoDB 3.4+;驱动程序/外壳';错误,java,mongodb,spring-data-mongodb,mongodb-atlas,Java,Mongodb,Spring Data Mongodb,Mongodb Atlas,我开始了一个全新的Kotlin+Spring Boot项目。在这里,我想通过SpringDataMongoDB连接到我的MongoAtlas集群 我通过应用程序设置了非常简单的配置。属性(已定义占位符): 到目前为止,我的努力: 我下载了一个新的JDK 11,以确保我有适当的基础(从:),并根据这个线程的建议() 我改为JDK1.8只是为了尝试一下 我改变了mongourl风格(在当时的driver 3.6和更高版本之间)-没有帮助 在这个问题中,我看到有人使用了spring boot的非启动

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

我通过
应用程序设置了非常简单的配置。属性
(已定义占位符):

到目前为止,我的努力:
  • 我下载了一个新的JDK 11,以确保我有适当的基础(从:),并根据这个线程的建议()
  • 我改为JDK1.8只是为了尝试一下
  • 我改变了mongourl风格(在当时的driver 3.6和更高版本之间)-没有帮助
  • 在这个问题中,我看到有人使用了spring boot的非启动依赖项。然而,mongo stuff并没有自动检测到这一点,这不是我想要开发的方式
  • 我试图调试mongo驱动程序正在做什么,但是。。。梅不知道出了什么问题
这些是我与此任务相关的依赖项:

// 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"
    }
}

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

相关,问题实际上是JDK。我在每个地方都改成了14

  • 项目结构模块和项目
  • 格拉德尔
  • build.gradle文件

那么您的驱动程序版本是什么?也可以在不使用spring boot等的情况下仅使用驱动程序来实现此功能。@D.SM请检查EDIT 1Try一个不同的java运行时,可能是使用不同操作系统的docker,并对驱动程序进行简单测试。Atlas共享层需要SNI。您可以尝试M10或更大的群集。
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"
    }
}
org.mongodb:mongodb-driver-core:4.0.5
org.mongodb:mongodb-driver-sync:4.0.5