Spring Boot Jpa如何封装一个BaseDao?

Jackie_GP Jackie_GP 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
怎么把springboot的jpa封装一个basedao,
public interface BaseDao<T, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T>
其他的dao,都继承这个BaseDao就可以呢?

而不是每一个Dao都继承JpaRepository这个。
比如:
public interface DepartmentDao extends JpaRepository<Department, Integer>, JpaSpecificationExecutor<Department>

这样正确
但是,如果public interface DepartmentDao extends BaseDao<Department, Integer>
就错误。
错误如下:
Error creating bean with name 'departmentDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property createObject found for type Department!
应该怎么写呢?
请大神帮忙!
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
Jackie_GP
Web 开发 81,107 成员 341,720 内容