新人在使用ssm時遇到的問題。

ssm新人,在使用ssm出現如下錯錯誤。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; 

按字面意思是spring配置文件有問題,於是瘋狂在spring配置文件上找,最後沒發現錯誤。

後來,檢查mapper.xml後才發現有重複的id。mapper是使用MyBatisGenerator逆向工程生成的,由於之前運行了兩次generator,所以猜測MyBatisGenerator生成的mapper.xml如果mapper文件已經存在則是在之前的文件上進行追加。並不會創建一個新的。

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