[英]How to configure SSL mongodb connection in YML file spring boot?
I was trying to setup a ssl mongodb connection from spring boot but I couldn't able to find a way to set a connection from YML
file(beacuse it's easy to maintain dev and prod environment). 我试图从春季启动中设置ssl mongodb连接,但是我找不到从
YML
文件设置连接的方法(因为这样很容易维护开发和生产环境)。 How can I add client.PEM and rootCA.pem keys to below connection? 如何将client.PEM和rootCA.pem密钥添加到下面的连接?
Please note this not a database administration question! 请注意,这不是数据库管理问题!
data:
mongodb:
authentication-database: admin
database: <database>
host: <host>
password: <password>
port: <port>
username: <username>
One way to resolve it is simple use URI string connect and database name in your application.yml file. 解决它的一种方法是简单地在application.yml文件中使用URI字符串连接和数据库名称。 Example:
例:
data: mongodb: database: <databaseName> uri: <mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]>
Example with SSL option: SSL选项示例:
mongodb://user:password@mongoServer:27017/?ssl=true MongoDB的://用户名:密码@ mongoServer:27017 / SSL =真
More info here https://docs.mongodb.com/manual/reference/connection-string/ 更多信息在这里https://docs.mongodb.com/manual/reference/connection-string/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.