关于springMVC与Mybatis整合时对sqlSessionFactory和init的问题

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\workplace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SpringMVC-mybatis\WEB-INF\classes\com\crud\mapper\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'userResultMap'. Cause: java.lang.ClassNotFoundException: Cannot find class: userResultMap

把代码贴出来,spring和mybatis整合可以看下这篇文章 http://58coding.com/article/detail/24659963087429989

问题是没有定义userResultMap


这里指定的 resultMap="userResultMap" 需要定义






才可以

<resultMap type="User" id="resultListUser">
<id column="id" property="id" />
<result column="userName" property="userName" />
<result column="userAge" property="userAge" />
<result column="userAddress" property="userAddress" />
</resultMap>
代码为啥没提交上去呢!补上;希望帮到你了

 首先检查你mybatis的配置文件是否存在问题,如果没问题再看你的映射mapper.xml文件是否有问题。
 但看你上面报的错,应该是程序的配置文件没有找到你对应程序的mapper映射文件。
注意看运行报的错误

Cause: java.lang.ClassNotFoundException: Cannot find class: userResultMap
没有找到类userResultMap,换句话说 你的配置让spring认为userResultMap是一个类
原因是
Could not resolve type alias 'userResultMap'
你将userResultMap配置在了typeAlias中?还是某个select的resultMap写的是userResultMap,但是没有id为userResultMap的

配置?