Description
When configuring MongoDB authentication, the configuration needs to happen either through the URI or through individual properties. Specifying spring.data.mongodb.uri
ignores spring.data.mongodb.username
and spring.data.mongodb.password
properties as we assume the ConnectionString
encapsulates all details.
In cases where endpoint config is provided with through an URL but authentication should be provided through properties (e.g. Vault, external property sources), it is not possible to do so.
In other areas, such as JDBC, some drivers can accept authentication as part of the JDBC URL and username/password properties are considered additionally.
Ideally, when both, URI and authentication, are configured, spring.data.mongodb.username
overrides what is specified through the connection string.
Related tickets: