没有为存储库配置支持 RepositoryOperations。检查您的配置并重试

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

尝试将 RxJavaCrudRepository 与带有 mongo db 的 Micronaut 数据一起使用。

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

从存储库获取值

private final GenericRepository repository;

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

依赖性

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

异常

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).

尝试使用 MongoClient 而不是存储库。

示例见此处:

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

或在这里:

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

我猜存储库不支持 mongodb。这就是你得到异常的原因,因为没有真正的数据库可以与 repo 一起使用。