首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >org.springframework.data.repository.query.QueryMethodEvaluationContextProvider :ClassNotFoundException

org.springframework.data.repository.query.QueryMethodEvaluationContextProvider :ClassNotFoundException
EN

Stack Overflow用户
提问于 2018-10-15 02:44:58
回答 1查看 1.7K关注 0票数 2

在使用PostgreSQL作为数据库的现有Spring Boot应用程序中,在Getting Started with R2DBC video之后,我将一些存储库转换为reactive。应用程序在转换之前工作。在我尝试启动应用程序后,我得到以下错误:

代码语言:javascript
复制
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'albumReactResource' defined in file [/app/classes/com/mycompany/myapp/web/rest/react/AlbumReactResource.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'albumReactRepository' defined in class path resource [com/mycompany/myapp/config/ReactDatabaseConfig.class]: Unsatisfied dependency expressed through method 'albumReactRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'r2dbcRepositoryFactory' defined in class path resource [com/mycompany/myapp/config/ReactDatabaseConfig.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory] from ClassLoader [sun.misc.Launcher$AppClassLoader@4e0e2f2a]
...
gallery-app_1         | Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.query.QueryMethodEvaluationContextProvider
gallery-app_1         |  at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
gallery-app_1         |  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
gallery-app_1         |  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
gallery-app_1         |  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
gallery-app_1         |  ... 51 common frames omitted

QueryMethodEvaluationContextProvider类应该在那里。我猜数据库配置不能与现有的数据库和Spring数据配置共存。

Spring Boot版本为2.0.5.RELEASE,相关依赖如下:

代码语言:javascript
复制
compile "org.springframework.boot:spring-boot-starter-webflux"
compile "org.springframework.data:spring-data-jdbc:1.0.0.r2dbc-SNAPSHOT"
compile "io.r2dbc:r2dbc-postgresql:1.0.0.M5"

下面是与视频代码相同的数据库配置:

配置公共类ReactDatabaseConfig {

代码语言:javascript
复制
@Bean
PostgresqlConnectionFactory connectionFactory(){
    return new PostgresqlConnectionFactory(

            PostgresqlConnectionConfiguration.builder()
                .host("localhost")
                .database("gallery")
                .username("postgres")
                .password("")
                .build()
        );
    }

    @Bean
    DatabaseClient databaseClient(ConnectionFactory connectionFactory){

        return DatabaseClient.builder()
                .connectionFactory(connectionFactory)
                .build();
    }

    @Bean
    R2dbcRepositoryFactory r2dbcRepositoryFactory(DatabaseClient client){

        RelationalMappingContext context = new RelationalMappingContext();
        context.afterPropertiesSet();

        return new R2dbcRepositoryFactory(client, context);
    }

    @Bean
    AlbumReactRepository albumReactRepository(R2dbcRepositoryFactory factory){
        return factory.getRepository(AlbumReactRepository.class); <-- exceptions occurs
    }
 ...
}

一些相关的依赖信息如下:

代码语言:javascript
复制
+--- org.springframework.data:spring-data-jdbc:1.0.0.r2dbc-SNAPSHOT
|    +--- org.springframework.data:spring-data-commons:2.1.1.BUILD-SNAPSHOT -> 2.0.10.RELEASE (*)
...
+--- org.springframework.security:spring-security-data -> 5.0.8.RELEASE
|    +--- javax.xml.bind:jaxb-api:2.3.0
|    +--- org.springframework.data:spring-data-commons:2.0.10.RELEASE (*)
...
|    +--- org.springframework.data:spring-data-jpa:2.0.10.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:2.0.10.RELEASE

如何解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2018-11-12 14:20:39

确保AlbumReactRepository正在扩展org.springframework.data.repository.reactive.ReactiveCrudRepository

而不是

代码语言:javascript
复制
org.springframework.data.repository.CrudRepository
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52805942

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档