MongoDB 3.6与Spring的Compass连接

huangapple 未分类评论48阅读模式
英文:

MongoDb 3.6 Compass connection with Spring

问题

我正在构建一个 Java REST API 后端 Spring 应用程序,需要将其与 MongoDB Compass 版本-Cloud 集群连接起来。这意味着我需要使用以下 URI 来连接数据库。

spring.data.mongodb.uri=mongodb+srv://<USERNAME>:<PASSWORD>@<ClUSTER-NAME>-<INSTANCE-ID>/<DATABASE-NAME>?retryWrites=true

我尝试了按照这个教程进行操作:https://www.devglan.com/spring-boot/spring-boot-mongodb-configuration 但是遇到一个错误,指出 SimpleMongoDbFactory 方法已被弃用。不幸的是,我没有找到另一个教程来完成我的项目。另外,使用 Spring Boot 是必要的吗?

这是我第一次尝试建立这种连接,我不知道还应该做些什么。非常感谢您的帮助!

英文:

I am building a java rest api back end spring application and I need to connect it with mongo db compass edition- cloud-cluster. That means that I need to use this uri, in order to connect to the database.

spring.data.mongodb.uri=mongodb+srv://&lt;USERNAME&gt;:&lt;PASSWORD&gt;@&lt;ClUSTER-NAME&gt;-&lt;INSTANCE-ID&gt;/&lt;DATABASE-NAME&gt;?retryWrites=true

I have tried to follow this tutorial: https://www.devglan.com/spring-boot/spring-boot-mongodb-configuration but I got an error, saying that this method SimpleMongoDbFactory is depricated. Unfortunately, I could not find an another tutorial so that I could finish my project. Also is it necessary to use spring boot ?

It is the first time that I am trying this connection and I do not know what else to do.
Any help appreciated !

huangapple
  • 本文由 发表于 2020年4月7日 06:33:54
  • 转载请务必保留本文链接:https://java.coder-hub.com/61070007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定