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