学习spring boot,遇到@Autowired总是报错,自己折腾了半天也没搞定,请大家帮忙看看:
这是controller和dao的调用和目录结构
这是一个简单的dao,参照书上写的
结果启动时报错BeanCreationException:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'userController':
Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.caizhaotu.dao.user.UserRepository com.caizhaotu.controller.user.UserController.userRepository;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.util.NoSuchElementException
好像是spring注入bean的时候错误,但不知道这个springboot改怎么配置,因为我看得书上都说是自动配置的啊?