1. 程式人生 > >【SSM】報錯及解決

【SSM】報錯及解決

 

  • spring mvc mybatis 整合錯誤1

(放置事務註解的位置錯誤)(表現:直接訪問.jsp,.html報錯,寫一個測試類,測試mapper,報錯)
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionDecorator for element [annotation-driven]

  • 整合錯誤2(dataSource拼寫錯誤)

Offending resource: class path resource [applicationContext.xml]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSouorce' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSouorce' is defined

  • 整合錯誤3(springmvc.xml 註解驅動配置錯誤 修改後未解決,仍然報一下錯誤。註解@Service 和@Controller,仍然報錯。最後直接專案刪了,重新copy配置檔案,問題解決了。等於說是又建了一個,autowired dependencies failed還是沒有解決)    

Error creating bean with name 'itemsController': Injection of autowired dependencies failed; 
//錯誤的建立名為‘xxx’(原因):自動接入依賴的注入失敗
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.t.service.ItemService com.t.controller.ItemsController.itemService;
//巢狀的異常是xx.BeanCreationException(原因):不能夠自動接入域:private com.t.service.ItemService ,com.t.controller.ItemsController.itemService;

 nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.t.service.ItemService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
 /*
qualifying
adj.    使具有資格的;
v.    (使) 具有資格( qualify的現在分詞 ); 有權; 達標; 使所說的話語氣減弱(或更具體等);
 */

 //巢狀的異常是xx..NoSuchBeanDefinitionException:沒有具有資格的型別為xx的bean 被找到 為依賴:額外的在至少一個 有資格作為自動接入顯而易見的bean。
 依賴註解: {@org.springframework.beans.factory.annotation.Autowired(required=true)}