After checking the information on the Internet, you need to rewrite the buildsqlsessionfactory method in sqlsessionfactorybean and replace the original 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>
Mybatis ing file error Tomcat cannot be started, and no exception is reported