英文:
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://<USERNAME>:<PASSWORD>@<ClUSTER-NAME>-<INSTANCE-ID>/<DATABASE-NAME>?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 !
专注分享java语言的经验与见解,让所有开发者获益!
评论