为了账号安全,请及时绑定邮箱和手机立即绑定

spring boot不能注入JpaRepository接口,提示找不到bean

spring boot不能注入JpaRepository接口,提示找不到bean

慕哥9229398 2019-03-01 10:59:08
Field studentRepository in com.example.demo.StudentController required a bean of type 'com.example.demo.StudentRepository' that could not be found. Action: Consider defining a bean of type 'com.example.demo.StudentRepository' in your configuration. @RestController public class StudentController { @Autowired private StudentRepository studentRepository; @GetMapping(value = "/findAll") public List<Student> studentList(){ return studentRepository.findAll(); } } StudentRepository 继承 JpaRepository,应该是个最简单的例子了 一共就一个包,SpringBootApplication和Controller都放在一个包下面,应该不会出现网上的顺序的问题
查看完整描述

3 回答

?
幕布斯7119047

TA贡献1794条经验 获得超8个赞

我自己解决了,jpa的包冲突了。

查看完整回答
反对 回复 2019-03-01
  • 3 回答
  • 0 关注
  • 2557 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号