title: Mongodb replicaset authetication failing from spring boot
body: <p>I have 3 instance mongodb replicaset including 1 arbiter in 3 different ec2 instance. From mongo console I am able to connect to replica set.
  But when I try to build/deploy my dockerized spring boot apllication in the primary ec2 instance it gives below exception</p>
  <pre><code>Caused by: org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='&lt;usrName&gt;', source='&lt;source&gt;', password=&lt;hidden&gt;, mechanismProperties=&lt;hidden&gt;}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='&lt;usrName&gt;', source='&lt;source&gt;', password=&lt;hidden&gt;, mechanismProperties=&lt;hidden&gt;}
  Caused by: com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='&lt;usrName&gt;', source='&lt;source&gt;', password=&lt;hidden&gt;, mechanismProperties=&lt;hidden&gt;}
  Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server &lt;Primary-Host&gt;:27017. The full response is {&quot;operationTime&quot;: {&quot;$timestamp&quot;: {&quot;t&quot;: 1601217500, &quot;i&quot;: 1}}, &quot;ok&quot;: 0.0, &quot;errmsg&quot;: &quot;Authentication failed.&quot;, &quot;code&quot;: 18, &quot;codeName&quot;: &quot;AuthenticationFailed&quot;, &quot;$clusterTime&quot;: {&quot;clusterTime&quot;: {&quot;$timestamp&quot;: {&quot;t&quot;: 1601217500, &quot;i&quot;: 1}}, &quot;signature&quot;: {&quot;hash&quot;: {&quot;$binary&quot;: {&quot;base64&quot;: &quot;KSwBAZHnhcqmjdsAy9HHVB8+yZQ=&quot;, &quot;subType&quot;: &quot;00&quot;}}, &quot;keyId&quot;: 6876114453302083588}}}
  </code></pre>
  <p>Spring data mongodb properties used while connecting to replicaset</p>
  <pre><code>spring.data.mongodb.uri=mongodb://&lt;usrName&gt;:&lt;password&gt;@&lt;host-primary&gt;:27017,&lt;host-secondary&gt;:27017/&lt;dbName&gt;?&lt;replicaset name&gt;
  spring.data.mongodb.auto-index-creation = true
  </code></pre>
  <p>Where as when I try to build/deploy using below properties i.e single node connection this is getting successfull</p>
  <pre><code>spring.data.mongodb.host=&lt;Primary-Host&gt;
  spring.data.mongodb.port=27017
  spring.data.mongodb.database=&lt;database name&gt;
  spring.data.mongodb.authentication-database=admin
  spring.data.mongodb.username=&lt;user name&gt;
  spring.data.mongodb.password=&lt;password&gt;
  spring.data.mongodb.auto-index-creation = true
  </code></pre>