在SSM項目中简烘,經(jīng)常因為mybatis文件報錯而項目啟動不了嗜侮,通過配置可以在控制臺輸出xml文件報錯的信息检号。
package com.findError;
import java.io.IOException;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.core.NestedIOException;
public class BeanFactory extends SqlSessionFactoryBean {
@Override
protected SqlSessionFactory buildSqlSessionFactory() throws IOException {
try{
return super.buildSqlSessionFactory();
}catch(NestedIOException e){
e.printStackTrace();
throw new NestedIOException("Failed to parse mapping resource:",e.getCause());
}
}
}