Error creating bean with name 'bookShopListImpl': Injection of autowired dependencies failed;

版权声明:博客知识产权来源命运的信徒,切勿侵权 https://blog.csdn.net/qq_37591637/article/details/85274970

Could not autowire field

 Error creating bean with name 'bookShopListImpl': Injection of autowired dependencies failed;

org.springframework.beans.factory.BeanCreationException: Could not autowire field:

private cn.com.dao.service.BookShopServiceImpl cn.com.dao.service.BookShopListImpl.bookShopServiceImpl;

java.lang.IllegalArgumentException: Can not set cn.com.dao.service.BookShopServiceImpl field


错误代码:

1、BookShopDaoImpl 继承BookShopDao 接口

public class BookShopDaoImpl implements BookShopDao {

2、在自动装配的时候用的是BookShopDaoImpl 类型

    @Autowired
    private BookShopDaoImpl  bookShopDaoImpl;

正确代码:

扫描二维码关注公众号,回复: 4689126 查看本文章

2、在自动装配的时候用的是BookShopDao 类型

    @Autowired
    private BookShopDao  bookShopDaoImpl;


在许多的时候,子类继承接口的时候,默认的类型都是接口类型!!!

猜你喜欢

转载自blog.csdn.net/qq_37591637/article/details/85274970