2016-04-22 48 views

回答

0

默認春天數據蒙戈db是連接你的本地主機,如果你不是在applicaiton.properties文件中聲明任何connfiguration性能

例如

推出的MongoDB服務器mongod命令和發射後您的應用程序,使任何CRUD操作見登錄您的命令提示符

如果您的應用程序需要特殊的服務器uri或任何配置屬性

添加application.properties文件,這個屬性和例如配置

spring.data.mongodb.uri=mongodb://user:[email protected]:12345,mongo2.example.com:23456/test 

這個配置URI與colleciton名

,也宣告主機和端口與此

spring.data.mongodb.host=mongoserver 
spring.data.mongodb.port=27017 

也更屬性知識(例如:用戶名和密碼設置):https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

連接功能在這裏: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-connecting-to-mongodb