gpt4 book ai didi

spring - 通用代码因 Spring 数据和 Querydsl 失败

转载 作者:行者123 更新时间:2023-12-04 08:48:37 25 4
gpt4 key购买 nike

我用 querydsl这就是为什么我不需要像 findByName() 这样的方法我所有的存储库界面都是空的。

所以我尝试制作通用代码以避免使用空方法的重复接口(interface),因为我的实体中有许多由 hibernate 映射的类。

public interface GenericResposotory<T> 
extends JpaRepository<T, Integer>, QueryDslPredicateExecutor<T> {

}

当我运行我的服务器时,我收到了这个错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericResposotory': 
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: Not an managed type: class java.lang.Object

还有没有办法像我尝试做的那样制作通用存储库?

最佳答案

Spring data 尝试为您创建的所有扩展 JpaRepository 的接口(interface)创建 bean。如果您想拥有一种不会使用的基础存储库,请将您的接口(interface)标记为 @NoRepositoryBean

关于spring - 通用代码因 Spring 数据和 Querydsl 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27055304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com