在做的项目,有时候tomcat启动会陷入死循环,一直在启动中,无法结束,自然也不会报异常.
查了一下网上的资料,需要自己重写一下SqlSessionFactoryBean中的buildSqlSessionFactory方法,并替换原有的SqlSessionFactoryBean
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());
}
}
}
<bean id="sqlSessionFactory" class="com.izhenglan.merchant.test.bean.BeanFactory">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:config/mybatis-config.xml"/>
<property name="mapperLocations" value="classpath*:mapper/*.xml"/>
</bean>
作者:AnyL8023
链接:https://www.jianshu.com/p/5020325056f4
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。