今天在学习spring的时候出现了这样的一个问题,
Could not autowire. No beans of 'CheckoutService' type found.
由于自己使用的是注释的方式来添加beans
当时是在service层创建了一个类,在controller层调用了这个service层的类,将其作为了一个属性,并添加了Autowired
然而我却忘记在service这个类本身添加注解,使其变成一个spring的bean,导致出现了
Could not autowire. No beans of 'xxx' type found.
总结:在当你想要去自动注入一个类的属性时,一定要先把他变成spring的bean才能进行autowire!
最终通过在service层的类上 添加@service解决了这个问题