title: Spring boot 2.0.5.RELEASE and mongo 4.0 connection issues
body: <p>I am following the Accessing Data with MongoDB tutorial on <a href="https://spring.io/guides/gs/accessing-data-mongodb/" rel="nofollow noreferrer">Spring web site</a><br>
  I Installed Mongo DB server version 4 as a service<br>
  Its authentication is working fine when I connect to it using a a client.</p>
  
  <p>I am facing the issue below:  </p>
  
  <pre><code>MongoCommandException: Command failed with error 18: 'Authentication failed'
  </code></pre>
  
  <p>I see that the code is using mongodb-driver-core-3.6.4.jar that is not compatible with server version 4 </p>
  
  <p>How to go about upgrading the driver only without messing the project?<br>
  Why are they using spring-boot-starter-data-mongodb and not mongodb-driver-sync ?</p>
  
  <pre><code>com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='petUser', source='pets', password=&lt;hidden&gt;, mechanismProperties={}}
      at com.mongodb.connection.SaslAuthenticator.wrapException(SaslAuthenticator.java:162) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator.access$200(SaslAuthenticator.java:39) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:68) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:46) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:168) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:46) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.DefaultAuthenticator.authenticate(DefaultAuthenticator.java:32) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:122) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:52) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:127) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:114) ~[mongodb-driver-core-3.6.4.jar:na]
      at java.lang.Thread.run(Unknown Source) [na:1.8.0_181]
  Caused by: com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server localhost:27014. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }
      at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:164) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:295) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.CommandHelper.sendAndReceive(CommandHelper.java:84) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:34) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator.sendSaslStart(SaslAuthenticator.java:119) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator.access$000(SaslAuthenticator.java:39) ~[mongodb-driver-core-3.6.4.jar:na]
      at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:52) ~[mongodb-driver-core-3.6.4.jar:na]
      ... 9 common frames omitted
  </code></pre>
  
  <p>Here is the project POM:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;gs-accessing-data-mongodb&lt;/artifactId&gt;
      &lt;version&gt;0.1.0&lt;/version&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.0.5.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>Update</strong><br>
  maven dependency-plugin show dependency on mongodb:mongodb-driver-core:jar:3.8.0<br>
  So Im not sure where is this  mongodb-driver-core-3.6.4.jar coming from?</p>
  
  <pre><code>[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ demo ---
  [INFO] com.replaceme:demo:jar:0.0.1-SNAPSHOT
  [INFO] +- org.springframework.boot:spring-boot-starter-data-mongodb:jar:2.0.5.RELEASE:compile
  [INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.5.RELEASE:compile
  [INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.5.RELEASE:compile
  [INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
  [INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
  [INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
  [INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
  [INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
  [INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
  [INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:runtime
  [INFO] |  +- org.mongodb:mongodb-driver:jar:3.8.0:compile
  [INFO] |  |  +- org.mongodb:bson:jar:3.8.0:compile
  [INFO] |  |  \- org.mongodb:mongodb-driver-core:jar:3.8.0:compile
  [INFO] |  \- org.springframework.data:spring-data-mongodb:jar:2.0.10.RELEASE:compile
  [INFO] |     +- org.springframework:spring-context:jar:5.0.9.RELEASE:compile
  [INFO] |     +- org.springframework:spring-beans:jar:5.0.9.RELEASE:compile
  [INFO] |     +- org.springframework:spring-expression:jar:5.0.9.RELEASE:compile
  [INFO] |     +- org.springframework.data:spring-data-commons:jar:2.0.10.RELEASE:compile
  </code></pre>
  
  <p><strong>Update 2</strong><br>
  I removed all mongodb jars from my M2 folder<br>
  and added mongodb properties to the pom       section:</p>
  
  <pre><code>    &lt;mongodb.version&gt;3.8.0&lt;/mongodb.version&gt;
  </code></pre>
  
  <p>Now I see a new error:</p>
  
  <pre><code>***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  An attempt was made to call the method com.mongodb.connection.DefaultClusterFactory.createCluster(Lcom/mongodb/connection/ClusterSettings;Lcom/mongodb/connection/ServerSettings;Lcom/mongodb/connection/ConnectionPoolSettings;Lcom/mongodb/connection/StreamFactory;Lcom/mongodb/connection/StreamFactory;Ljava/util/List;Lcom/mongodb/event/CommandListener;Ljava/lang/String;Lcom/mongodb/client/MongoDriverInformation;Ljava/util/List;)Lcom/mongodb/connection/Cluster; but it does not exist. Its class, com.mongodb.connection.DefaultClusterFactory, is available from the following locations:
  
      jar:file:/C:/Users/winUser/.m2/repository/org/mongodb/mongodb-driver-core/3.8.0/mongodb-driver-core-3.8.0.jar!/com/mongodb/connection/DefaultClusterFactory.class
  
  It was loaded from the following location:
  
      file:/C:/Users/winUser/.m2/repository/org/mongodb/mongodb-driver-core/3.8.0/mongodb-driver-core-3.8.0.jar
  
  
  Action:
  
  Correct the classpath of your application so that it contains a single, compatible version of com.mongodb.connection.DefaultClusterFactory
  </code></pre>
  
  <p><strong>Update 3</strong>    </p>
  
  <p>It is running fine outside eclipse,<br>
  In command line I did:</p>
  
  <pre><code>mvn package  
  cd target
  java -jar .\demo-0.0.1-SNAPSHOT.jar
  </code></pre>
  
  <p>And its running fine, not sure what is the issue within Eclipse.</p>