Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fongo - OperationExecutor not found

I would like to use fongo 2.0.x in my Spring boot application, but I getting errror

Error:(23, 44) java: cannot access com.mongodb.operation.OperationExecutor
class file for com.mongodb.operation.OperationExecutor not found

Here is my AbstractMongoConfiguration

@Configuration
@ComponentScan("com.foo")
public class MongoDbConfig extends AbstractMongoConfiguration {

    @Override
    protected String getDatabaseName() {
        return "demo";
    }

    @Override
    public Mongo mongo() throws Exception {
        return new Fongo(getDatabaseName()).getMongo(); //this line throws the error
    }
}
like image 864
richersoon Avatar asked Oct 19 '22 05:10

richersoon


1 Answers

From the Fongo documentation:

It has a "provided" dependency on the mongo-java-driver and was tested with 2.13.0 and 3.0.1.

So Fongo wants mongo-java-driver on the classpath, and I'm guessing you don't have it (or at least not in the test scope).

So make sure the following is in your build script:

For Maven:

<dependency>
  <groupId>org.mongodb</groupId>
  <artifactId>mongo-java-driver</artifactId>
  <version>3.4.1</version>
  <scope>test</scope>
</dependency>

For Gradle:

testCompile 'org.mongodb:mongo-java-driver:3.4.1'
like image 60
Hanno Avatar answered Oct 21 '22 04:10

Hanno