我有一个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)
班级名称已更改。
答案 0 :(得分:1)
您没有提供任何代码,但我假设您在MyClassVO
的构造函数中有一个类型为MyServiceImpl
的参数
因此,Spring尝试注入类型为MyClassVO
的bean。但是我认为MyClassVO
不是Spring Bean。
因此,您有两种选择:
MyClassVO
注释@Component
来制作Spring Bean 由于VO通常是Value Object的缩写,我认为选项1是更好的解决方案。