为什么在Spring Boot期间找不到bean? [英] Why is bean not found during Spring Boot?
问题描述
此问题已解决.请在下面查看检查后的答案.
我将DAO重新配置为更方便的方式(通过使用JpaRepository),而不是手动完成所有样板代码.但是现在每次我启动Spring Application时,都会出现以下错误:
I reconfigured my DAOs to a more convenient way (by using JpaRepository) instead of doing all that boilerplate code manually. But now everytime I start the Spring Application it gives me the following error:
***************************
申请无法开始
说明:
DAO.UserDAOService中的字段userRepository需要找不到类型为'DAO.UserRepository'的bean.
Field userRepository in DAO.UserDAOService required a bean of type 'DAO.UserRepository' that could not be found.
注入点具有以下注释: -@ org.springframework.beans.factory.annotation.Autowired(required = true)
The injection point has the following annotations: - @org.springframework.beans.factory.annotation.Autowired(required=true)
动作:
考虑在您的配置中定义类型为'DAO.UserRepository'的bean.
Consider defining a bean of type 'DAO.UserRepository' in your configuration.
以退出代码1完成的过程
Process finished with exit code 1
********************************************************************
推荐答案
解决方案:只需在您的Spring应用程序所在的同一包中创建子包即可.
SOLUTION: Just create sub-packages in the same package where you have your Spring appliciation located.
EXAMPLE OF SOLUTION CAN BE FOUND HERE: 'Field required a bean of type that could not be found.' error spring restful API using mongodb
这篇关于为什么在Spring Boot期间找不到bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!