Spring Data JPA存储库 [英] Spring Data JPA Repositories

查看:174
本文介绍了Spring Data JPA存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库定义,如

I have a repository definition like

public interface UserRepository extends CrudRepository<User, Long> {}

在Spring上下文文件中我有

In the Spring context file I have

<jpa:repositories base-package="my.package"/>

然后我尝试做类似的事情

Then I try to do something like

new Repositories(applicationContext).getRepositoryFor(User.class);

但我收到错误


方法getRepositoryFor,带签名
(Ljava / lang / Class;)Lorg / springframework / data / repository / CrudRepository;
不适用于此对象

Method "getRepositoryFor" with signature "(Ljava/lang/Class;)Lorg/springframework/data/repository/CrudRepository;" is not applicable on this object

有没有人知道我做错了什么?

Does anyone have any idea what could have I done wrong?

推荐答案

这更像是Spring Data JPA模块和Spring Data Commons之间的版本不兼容。确保使用从您使用的Spring Data JPA版本的 pom.xml 中引用的Spring Data Commons版本。或者,甚至更好:根本不要声明对Spring Data Commons的依赖。

This feels more like a version incompatibility between the Spring Data JPA module and Spring Data Commons. Make sure you use the version of Spring Data Commons that is referred to from the pom.xml of the Spring Data JPA version you use. Or, even better: do not declare a dependency on Spring Data Commons at all.

这篇关于Spring Data JPA存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆