Micronaut data : No backing RepositoryOperations configured for repository

五迷三道 提交于 2021-02-20 19:25:33

问题


I am getting this following exception when I try configuring micronaut-data with inmemory h2 database and Jpa.
I have been following the documentation

I created the project from command line with maven as build tool. I have the following

<dependency>
     <groupId>io.micronaut.configuration</groupId>
      <artifactId>micronaut-jdbc-tomcat</artifactId>
      <scope>runtime</scope>
    </dependency>
<dependency>
     <groupId>com.h2database</groupId>
     <artifactId>h2</artifactId>
     <scope>runtime</scope>
</dependency>
<dependency>
     <groupId>io.micronaut.data</groupId>
     <artifactId>micronaut-data-hibernate-jpa</artifactId>
     <version>1.0.0.M3</version>
</dependency>

And Also I have added annotation processor like this

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
   ......
  <configuration>
    ...
    <annotationProcessorPaths>
      <path>
        <groupId>io.micronaut</groupId>
        <artifactId>micronaut-inject-java</artifactId>
        <version>${micronaut.version}</version>
      </path>
      <path>
        <groupId>io.micronaut</groupId>
        <artifactId>micronaut-validation</artifactId>
        <version>${micronaut.version}</version>
      </path>
      <path>
        <groupId>io.micronaut.data</groupId>
        <artifactId>micronaut-data-processor</artifactId>   
        <version>1.0.0.M3</version>
      </path>
    </annotationProcessorPaths>
  </configuration>
  .....
</plugin>

My Entity class and Repository class are exactly as mentioned in the guide. When I try to save using the repository, I get this exception

18:16:37.787 [pool-1-thread-3] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: No backing RepositoryOperations configured for repository. Check your configuration and try again
io.micronaut.context.exceptions.ConfigurationException: No backing RepositoryOperations configured for repository. Check your configuration and try again
..............................
Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.data.operations.RepositoryOperations] 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).

I have already looked into this. This is completely different and it doesn't help my issue.

Interestingly if I change the order of micronaut data annotation processsor I mean If I put like this

<plugin>                                                    
  <groupId>org.apache.maven.plugins</groupId>               
  <artifactId>maven-compiler-plugin</artifactId>            
   ......                                                   
  <configuration>                                           
    ...                                                     
    <annotationProcessorPaths>                              
      <path>                                                
        <groupId>io.micronaut</groupId>                     
        <artifactId>micronaut-inject-java</artifactId>      
        <version>${micronaut.version}</version>             
      </path>                                               
      <path>                                                
        <groupId>io.micronaut</groupId>                     
        <artifactId>micronaut-validation</artifactId>       
        <version>${micronaut.version}</version>             
      </path>                                               
      <path>                                                
        <groupId>io.micronaut.data</groupId>                
        <artifactId>micronaut-data-processor</artifactId>   
        <version>1.0.0.M3</version>                         
      </path>                                               
    </annotationProcessorPaths>                             
  </configuration>                                          
  .....                                                     
</plugin>  

I get a different exception.

Internal Server Error: All possible Introduction advise exhausted and no implementation found for method: Iterable saveAll(Iterable entities) 

Any pointers are much appreciated.


回答1:


I was getting this error and the solution for my case was to add the following to the application.yml:

jpa:
  default:
    properties:
      hibernate:
        bytecode:
          provider: none

This is based on the example project here: https://github.com/micronaut-projects/micronaut-data/blob/v1.0.0.M3/examples/example-jpa/src/main/resources/application.yml#L15




回答2:


The documentation was incomplete. Did a pull request (https://github.com/micronaut-projects/micronaut-data/pull/197) with the documentation update. It has been accepted. The updated documentation can be found here

Need another dependency for this to work

<dependency>
    <groupId>io.micronaut.data</groupId>
    <artifactId>micronaut-data-hibernate-jpa</artifactId>
</dependency>



回答3:


Add the model entity package path to the application.yml:

jpa:
default:
packages-to-scan:
  - 'com.entity' 

kindly add the component scan path in yml file because app entity not able to find



来源:https://stackoverflow.com/questions/58308475/micronaut-data-no-backing-repositoryoperations-configured-for-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!