新人在使用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文件已经存在则是在之前的文件上进行追加。并不会创建一个新的。

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