spring5整合mybatis3.4.6配置mapperLocations错误
凶羊 2018-12-19 06:07:37 配置spring5和mybatis3.4.6时候配置一直报错,快搞疯了
<!-- 配置MyBatis SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:mappers/*.xml" />
</bean>
上面这行红色字体的代码注释掉就可以通过了,不注释掉就报错:
Error creating bean with name 'sqlSessionFactory' defined in file [E:\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\note\WEB-INF\classes\conf\spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\note\WEB-INF\classes\mappers\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [E:\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\note\WEB-INF\classes\mappers\UserMapper.xml]'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'cn.tedu.note.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: cn.tedu.note.entity.User