No backing RepositoryOperations configured for repository. Check your configuration and try again

1.3k views Asked by At

Trying to use RxJavaCrudRepository with Micronaut data with mongo db.

@Repository
public interface GenericRepository extends RxJavaCrudRepository<Product, Long> {
}

Getting the value from repository

private final GenericRepository repository;

    public ProductListener(GenericRepository repository) {
        this.repository = repository;
    }
    var item = this.repository.findAll();

Dependency

implementation("io.micronaut.data:micronaut-data-hibernate-jpa")
    implementation("io.micronaut.mongodb:micronaut-mongo-reactive")

Exception

io.micronaut.context.exceptions.ConfigurationException: No backing RepositoryOperations configured for repository. Check your configuration and try again

io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.data.operations.PrimaryRepositoryOperations] exists. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).

1

There are 1 answers

1
IEE1394 On BEST ANSWER

Try using the MongoClient not a repository.

See for example here:

https://github.com/ilopmar/micronaut-mongo-reactive-sample/blob/master/src/main/java/mongoreactive/MongoController.java

Or here:

http://mongodb.github.io/mongo-java-driver-reactivestreams/1.9/javadoc/com/mongodb/reactivestreams/client/MongoClient.html

I guess repositories are not supporting mongodb. Thats why you get the exception, cause no real database is there to be used with the repo.