【发布时间】:2021-01-30 06:04:34
【问题描述】:
由于以下错误而无法运行 springboot 应用程序(它说,“考虑在您的配置中定义一个类型为 'com.example.demo.DAOinter' 的 bean”。这里缺少什么) :-
请查看用于 Repository 注释的 Service 类和 DAOInter 接口的详细信息:-
- ServiceBusinessLayer 类
- DAOinter 类
当 DAOinter 接口中包含存储库注释时,为什么 autowired 在 ServiceBusinessLayer 类中不起作用?
分享包详情和SpringBootApplication类
【问题讨论】:
-
请分享SpringBootApplication类的代码
-
我不记得确切的错误,但可能是因为文件夹结构。如果您将具有 main 方法的类放在另一个文件夹/包中,而不是应该用作 bean 的类的父文件夹/包,应用程序将不会扫描所有类。然后应用程序不知道所有的 bean。考虑一下,还提供您的文件夹结构,我们可以看看这个。
-
确保DAOiniter在同一个包或者
@SpringBootApplication注解的类的子包中。这是必要的,因为组件扫描只发生在同一个包和子包中。 -
也许,this answer 会有所帮助。
-
请将代码和日志共享为代码格式的文本,而不是图像。
标签: spring-boot spring-security spring-data-jpa spring-data autowired