Skip to content
Advertisement

How to find a Bean instance of MongoRepository?

I am trying to use a MongoRepository, but Spring complains, that no instance of the MonoRepository-Interface is in the context.

JavaScript

The server complains:

JavaScript

my maven pom.xml:

JavaScript

How can I get a bean instance of my MongoRepository?

Advertisement

Answer

The dependency is incorrect.

spring-data-mongodb only makes it compile:

JavaScript

But you need additional dependencies, to make it run. For convenience you can import spring-boot-starter-data-mongodb, which will import all required artifacts as transitive dependencies:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement