需要找不到类型为'com.me.app.vo.MyClassVO'的bean

时间:2020-06-05 14:50:54

标签: spring spring-boot autowired dto

我有一个POJO类用作ValueObject类,以将DAO值显示在屏幕上。在服务类中,我已经自动连接了类对象。启动我的应用程序时出现错误提示。服务类用@Service注释,不确定我的VO类中缺少什么。我应该用@bean或其他注释它吗?

Parameter 5 of constructor in com.me.app.service.MyServiceImpl required a bean of type 'com.me.app.vo.MyClassVO' that could not be found.

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

班级名称已更改。

1 个答案:

答案 0 :(得分:1)

您没有提供任何代码,但我假设您在MyClassVO的构造函数中有一个类型为MyServiceImpl的参数

因此,Spring尝试注入类型为MyClassVO的bean。但是我认为MyClassVO不是Spring Bean。

因此,您有两种选择:

  1. 如果MyClassVO不应该是Spring Bean,则将其删除
  2. 通过MyClassVO注释@Component来制作Spring Bean

由于VO通常是Value Object的缩写,我认为选项1是更好的解决方案。