簡體   English   中英

無法使用spring數據連接到基於MongoDB Atlas的數​​據庫

[英]Cant connect to MongoDB Atlas based database using spring data

我們正在為我們的應用程序評估MongoDB Atlas Cloud ..我們在連接到DB時遇到問題..(Mongo shell正在連接,我們可以導入數據)

我們使用了Spring-Mongo( http://projects.spring.io/spring-data-mongodb/ )並使用了以下配置

組態:

<mongo:mongo-client id="mongoClient" host="${mongo.host}" port="${mongo.port}" credentials="MONGO_USER:MONGO_PASS@MONGO_DB"  >
        <mongo:client-options connections-per-host="50" threads-allowed-to-block-for-connection-multiplier="5000" />
     </mongo:mongo-client>
     <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
         <constructor-arg ref="mongoClient"/>
         <constructor-arg name="databaseName" value="${mongo.dbname}"/>
    </bean>

結果:com.mongodb.MongoSocketReadException:過早地到達流的末尾

(cap中的值被替換為實際配置。params。)

我們如何解決這個問題? 謝謝

使用URI時,請確保將authenticationDB聲明為“admin”數據庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM