Struts、Spring項目跳到InvocationTargetException(Throwable target)方法

最近在使用Struts、Spring開發項目的過程中,出現了一個很奇怪的問題,在執行Action類中的方法時,不能返回數據,debug後發現進入方法後會跳到下邊的這個類的方法中,然後控制檯報NullPointerException錯誤

/**
* Constructs a InvocationTargetException with a target exception.
*
* @param target the target exception
*/
public InvocationTargetException(Throwable target) {
   super((Throwable)null);  // Disallow initCause
   this.target = target;
}

原因:在spring中沒有配置實現類,所以dao沒有注入。調用方法的時候會調用invoke()方法,這個時候dao爲null,所以會報錯

解決辦法:

1.把該dao實現類在spring中的SqlMapConfig.xml配置一下,

<sqlMap resource="com/jiaonizuoren/dao/ibatis/sqlmap/video/VideoSource.xml"/>

2.配置後還是沒解決,最後發現是在applicationContext.xml 也沒有配置bean標籤 Dao和IbatisDao,配置完成後就成功解決了

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章