[英]BeanCreationException when Spring Data Repository extends Custom Repository
I have the following repository interface:我有以下存储库界面:
public interface FooRepository extends ReactiveMongoRepository<Foo, String>, CustomFooRepository {
}
And the following custom repository interface:以及以下自定义存储库接口:
public interface CustomFooRepository {
Flux<Foo> findFooByFilters(FooSearchParams params);
}
With the following implementation:通过以下实现:
@RequiredArgsConstructor
public class DefaultCustomFooRepository implements CustomFooRepository {
private final ReactiveFluentMongoOperations fluentMongoOps;
@Override
public Flux<Foo> findFooByFilter(FooSearchParams params) {
return fluentMongoOps
.query(Foo.class)
// using the received params to create a dynamic query
.all();
}
}
But the Application Context fails with the following error:但是应用程序上下文失败并出现以下错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooRepository' defined in com.foo.fooservice.foo.FooRepository defined in @EnableReactiveMongoRepositories declared on MongoReactiveRepositoriesRegistrar.EnableReactiveMongoRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property filter found for type Foo!
I used to follow this exact practice when I needed to add custom methods to a Spring Data repository and I never encountered any problems, am I doing something wrong or has the behavior changed recently?当我需要将自定义方法添加到 Spring 数据存储库时,我曾经遵循这种确切的做法,但我从未遇到任何问题,是我做错了什么还是最近行为发生了变化?
Found the problem.发现了问题。
The name of my custom repository implementation was DefaultCustomFooRepository
.我的自定义存储库实现的名称是
DefaultCustomFooRepository
。
Renaming it to CustomFooRepositoryImpl
fixed it.将其重命名为
CustomFooRepositoryImpl
修复了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.