Java 无法自动连接存储库服务Spring JPA
我试图在代码中使用用户存储库,但intellij给了我错误 非抽象bean不允许使用Java 无法自动连接存储库服务Spring JPA,java,spring,spring-mvc,jpa,intellij-idea,Java,Spring,Spring Mvc,Jpa,Intellij Idea,我试图在代码中使用用户存储库,但intellij给了我错误 非抽象bean不允许使用接口 我有以下设置 @实体 公共类用户{ @身份证 私人长id; 私有字符串名; 私有字符串lastName; 私有字符串profileUrl; 私人字符串电子邮件; 私有字符串位置; 受保护的用户(){}; 公共用户(字符串第一、字符串最后、字符串配置文件URL、字符串电子邮件、字符串位置){ this.firstName=first; this.lastName=last; this.profileUrl=
接口
我有以下设置
@实体
公共类用户{
@身份证
私人长id;
私有字符串名;
私有字符串lastName;
私有字符串profileUrl;
私人字符串电子邮件;
私有字符串位置;
受保护的用户(){};
公共用户(字符串第一、字符串最后、字符串配置文件URL、字符串电子邮件、字符串位置){
this.firstName=first;
this.lastName=last;
this.profileUrl=profileUrl;
this.email=电子邮件;
这个位置=位置;
}
公共用户(个人){
this.firstName=person.getName().getGivenName();
this.lastName=person.getName().getFamilyName();
this.profileUrl=person.getImage().getUrl();
this.email=person.getEmails().get(0.getValue();
this.location=person.getCurrentLocation();
}
}
公共接口UserRepository扩展了Crudepository{
列出findByProfileId(长id);
}
我曾尝试用@Service
和@Repository
对其进行注释,但没有任何效果
@组件
公共类UserRepositoryImpl{
@自动连线
私有用户存储库用户存储库;
公共无效剂量测定法(){
List byProfileId=userRepository.findByProfileId(100);
}
}
XML
在定义userRepository
bean的my spring.xml行中发生错误
提前感谢。我相信您只需要删除这一行:
<bean id="userRepository" class="com.planit.persistence.registration.UserRepository"/>
查看SpringData文档。
@Repository
缺失,请尝试在repo接口上方添加并删除Spring中不允许的bean声明。谢谢,Spring文档和示例中似乎缺失了这一点。