Error creating bean with name 'bookShopListImpl': Injection of autowired dependencies failed;
阿新 • • 發佈:2018-12-28
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
正確程式碼:
2、在自動裝配的時候用的是BookShopDao 型別
@Autowired
private BookShopDao bookShopDaoImpl;
在許多的時候,子類繼承介面的時候,預設的型別都是介面型別!!!