5

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
    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
richersoon
  • 4,682
  • 13
  • 44
  • 74
  • Your example is not complete. You need to actually provide the code which actually "throws" the error (specify which line that error message maps to) – Paul Stelian Jul 12 '16 at 18:53

1 Answers1

3

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'
Hanno
  • 563
  • 5
  • 15