如何在 application.properties 中为 MongoDB 设置等待队列倍数和最大池大小
How to set wait Queue Multiple and Max Pool Size in application.properties for MongoDB
最近从本地存储移动到位于 linode 中的数据库。我正在将所有项目移到那里,现在我必须对 mongo 数据库使用身份验证。我曾经使用uri配置:
spring.data.mongodb.uri=mongodb://localhost/testDatabase?waitQueueMultiple=500&maxPoolSize=1000
在 uri 中,我将 500 设置为等待队列值,将 1000 设置为最大池大小
出于安全考虑,现在我正在使用另一个配置:
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.host=127.0.0.1
spring.data.mongodb.port=27017
spring.data.mongodb.database=testDatabase
spring.data.mongodb.username=root
spring.data.mongodb.password=MySuperPassword
是否存在我可以设置等待队列和池大小值的字段?
或
我可以在 uri 中设置安全配置吗?
感谢您的帮助。
您可以在 spring.data.mongodb.uri
中同时设置 user/password 和额外的属性
spring.data.mongodb.authentication-database
需要一个单独的 属性.
参见Connecting to a MongoDB Database(它给出了副本集的示例,但原则仍然适用于您想要的属性)
You can set the spring.data.mongodb.uri property to change the URL and configure additional settings such as the replica set, as shown in the following example:
spring.data.mongodb.uri=mongodb://user:secret@mongo1.example.com:12345,mongo2.example.com:23456/test
If you use the Mongo 3.0 Java driver, spring.data.mongodb.host
and spring.data.mongodb.port
are not supported. In such cases, spring.data.mongodb.uri
should be used to provide all of the configuration.
另见 https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
也许问了很久,但终于找到了设置这个属性的正确方法,希望这对有同样问题的人有所帮助:D
mongodb://user:password@ip:port/databaseName?authSource=admin&waitQueueMultiple=1000&maxPoolSize=1000
最近从本地存储移动到位于 linode 中的数据库。我正在将所有项目移到那里,现在我必须对 mongo 数据库使用身份验证。我曾经使用uri配置:
spring.data.mongodb.uri=mongodb://localhost/testDatabase?waitQueueMultiple=500&maxPoolSize=1000
在 uri 中,我将 500 设置为等待队列值,将 1000 设置为最大池大小
出于安全考虑,现在我正在使用另一个配置:
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.host=127.0.0.1
spring.data.mongodb.port=27017
spring.data.mongodb.database=testDatabase
spring.data.mongodb.username=root
spring.data.mongodb.password=MySuperPassword
是否存在我可以设置等待队列和池大小值的字段?
或
我可以在 uri 中设置安全配置吗?
感谢您的帮助。
您可以在 spring.data.mongodb.uri
spring.data.mongodb.authentication-database
需要一个单独的 属性.
参见Connecting to a MongoDB Database(它给出了副本集的示例,但原则仍然适用于您想要的属性)
You can set the spring.data.mongodb.uri property to change the URL and configure additional settings such as the replica set, as shown in the following example:
spring.data.mongodb.uri=mongodb://user:secret@mongo1.example.com:12345,mongo2.example.com:23456/test
If you use the Mongo 3.0 Java driver,
spring.data.mongodb.host
andspring.data.mongodb.port
are not supported. In such cases,spring.data.mongodb.uri
should be used to provide all of the configuration.
另见 https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
也许问了很久,但终于找到了设置这个属性的正确方法,希望这对有同样问题的人有所帮助:D
mongodb://user:password@ip:port/databaseName?authSource=admin&waitQueueMultiple=1000&maxPoolSize=1000