I am trying to deploy my spring boot app to cloud foundry. However I am receiving the below error.
2016-02-19T16:54:29.57+0000 [App/0] ERR Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Usage of 'UserCredentials' with 'MongoClient' is no longer supported. Please use 'MongoCredential' for 'MongoClient' or just 'Mongo'.
2016-02-19T16:54:29.57+0000 [App/0] ERR at org.springframework.data.mongodb.core.SimpleMongoDbFactory.<init>(SimpleMongoDbFactory.java:137)
2016-02-19T16:54:29.57+0000 [App/0] ERR at org.springframework.data.mongodb.core.SimpleMongoDbFactory.<init>(SimpleMongoDbFactory.java:78)
2016-02-19T16:54:29.57+0000 [App/0] ERR at org.cloudfoundry.reconfiguration.org.springframework.cloud.service.document.MongoDbFactoryCreator.create(MongoDbFactoryCreator.java:46)
2016-02-19T16:54:29.57+0000 [App/0] ERR at org.cloudfoundry.reconfiguration.org.springframework.cloud.service.document.MongoDbFactoryCreator.create(MongoDbFactoryCreator.java:35)
2016-02-19T16:54:29.57+0000 [App/0] ERR at org.cloudfoundry.reconfiguration.org.springframework.cloud.Cloud.getServiceConnector(Cloud.java:257)
2016-02-19T16:54:29.57+0000 [App/0] ERR at org.cloudfoundry.reconfiguration.org.springframework.cloud.Cloud.getSingletonServiceConnector(Cloud.java:167)
2016-02-19T16:54:29.57+0000 [App/0] ERR at org.cloudfoundry.reconfiguration.spring.AbstractCloudServiceBeanFactoryPostProcessor.reconfigureBean(AbstractCloudServiceBeanFactoryPostProcessor.java:119)
It was my understanding the Spring Boot will automatically find the bound Mongo service and all the necessary user credentials and URI details, meaning I don't need to explicitly declare these variables.
Does anyone know why I am receiving this error and how I can solve it?
Here is my Java code snippet:
@Autowired
public MongoRepository(MongoClient mongo) {
this.mongo = mongo;
}
public long insert(Document document){
MongoDatabase db = mongo.getDatabase("test");
MongoCollection<Document> coll = db.getCollection("document");
coll.insertOne(document);
}
I am using Mongo3.0 java driver.
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.0.0</version><!--$NO-MVN-MAN-VER$-->
</dependency>