没有配置支持的RepositoryOperations用于仓库。请检查您的配置并重试。

huangapple go评论104阅读模式
英文:

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

问题

尝试在使用Micronaut数据与MongoDB时使用RxJavaCrudRepository

  1. @Repository
  2. public interface GenericRepository extends RxJavaCrudRepository<Product, Long> {
  3. }

从Repository中获取值:

  1. private final GenericRepository repository;
  2. public ProductListener(GenericRepository repository) {
  3. this.repository = repository;
  4. }
  5. var item = this.repository.findAll();

依赖项:

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

异常信息:

  1. io.micronaut.context.exceptions.ConfigurationException: No backing
  2. RepositoryOperations configured for repository. Check your
  3. configuration and try again
  4. io.micronaut.context.exceptions.NoSuchBeanException: No bean of type
  5. [io.micronaut.data.operations.PrimaryRepositoryOperations] exists.
  6. Make sure the bean is not disabled by bean requirements (enable trace
  7. logging for 'io.micronaut.context.condition' to check) and if the bean
  8. is enabled then ensure the class is declared a bean and annotation
  9. processing is enabled (for Java and Kotlin the 'micronaut-inject-java'
  10. dependency should be configured as an annotation processor).
英文:

Trying to use RxJavaCrudRepository with Micronaut data with mongo db.

  1. @Repository
  2. public interface GenericRepository extends RxJavaCrudRepository&lt;Product, Long&gt; {
  3. }

Getting the value from repository

  1. private final GenericRepository repository;
  2. public ProductListener(GenericRepository repository) {
  3. this.repository = repository;
  4. }
  5. var item = this.repository.findAll();

Dependency

  1. implementation(&quot;io.micronaut.data:micronaut-data-hibernate-jpa&quot;)
  2. implementation(&quot;io.micronaut.mongodb:micronaut-mongo-reactive&quot;)

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

得分: 1

尝试使用MongoClient,而不是repository。

例如在这里查看:

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

我猜repositories不支持mongodb。这就是为什么你会得到异常,因为没有真正的数据库可以与repository一起使用。

英文:

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.

huangapple
  • 本文由 发表于 2020年10月17日 12:29:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/64399009.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定