在SSM项目中,经常因为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());
}
}
}