I have a very weird situation. I'm running a Java spring-boot app that connects to a MongoDb instance. When I use the
spring.data.mongodb.uri=mongodb://{username}:{password}@{host}
field, I connect fine. But when I use:
spring.data.mongodb.host={host}
spring.data.mongodb.username={username}
spring.data.mongodb.password={password}
I get an authentication failure. What gives? Of course the values in the braces are exactly the same.
I included these in both settings:
spring.data.mongodb.authentication-database={auth-db}
spring.data.mongodb.database={mydb}
Other Details
The non-uri method works in one environment but not the one I am trying to fix.
Running both servers in the same Docker Swarm
Mongo ReplicaSet version 4.0.4
Java 8