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文件已經存在則是在之前的文件上進行追加。並不會創建一個新的。