gpt4 book ai didi

java - 为什么Spring Boot时找不到bean?

转载 作者:行者123 更新时间:2023-12-01 16:44:28 26 4
gpt4 key购买 nike

我以更方便的方式重新配置了 DAO(通过使用 JpaRepository),而不是手动执行所有样板代码。但现在每次我启动 Spring 应用程序时都会出现以下错误:

APPLICATION FAILED TO START  
Description:
Field userRepository in DAO.UserDAOService required a bean of type 'DAO.UserRepository' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:
Consider defining a bean of type 'DAO.UserRepository' in your configuration.
Process finished with exit code 1

最佳答案

解决方案:只需在 Spring 应用程序所在的同一包中创建子包即可。

解决方案示例可在此处找到:'Field required a bean of type that could not be found.' error spring restful API using mongodb

关于java - 为什么Spring Boot时找不到bean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55064074/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com