当前位置: 代码迷 >> VC/MFC >> spring mvc 项目运行报错:元素类型为 "resultMap" 的内容必须匹配 "(constructor?id*result
  详细解决方案

spring mvc 项目运行报错:元素类型为 "resultMap" 的内容必须匹配 "(constructor?id*result

热度:181   发布时间:2016-05-02 03:53:52.0
spring mvc 项目运行报错:元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result
报错内容:
Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deptInfoMapper' defined in file [F:\java\tomcat\webapps\FloodControl\WEB-INF\classes\com\sunny\dao\duty\DeptInfoMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\java\tomcat\webapps\FloodControl\WEB-INF\classes\com\sunny\mapping\duty\DutyPersonInfoMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 52; columnNumber: 15; 元素【类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminator?)"。】

解决:就是resultmap中的元素罗列顺序问题。
对的:
<resultMap id="onHashMapFun_3" type="java.util.HashMap">
   <id column="PERSON_ID" property="personId" jdbcType="INTEGER" />
    <result column="UNIT_ID" property="unitId" jdbcType="INTEGER" />
    <result column="UNIT_NAME" property="unitName" jdbcType="VARCHAR" />
    <result column="DEPT_ID" property="deptId" jdbcType="INTEGER" />
    <result column="DEPT_NAME" property="deptName" jdbcType="VARCHAR" />
    <result column="PERSON_NAME" property="personName" jdbcType="VARCHAR" />
  </resultMap>
错的:
<resultMap id="onHashMapFun_3" type="java.util.HashMap">
       <result column="UNIT_ID" property="unitId" jdbcType="INTEGER" />
    <result column="UNIT_NAME" property="unitName" jdbcType="VARCHAR" />
    <result column="DEPT_ID" property="deptId" jdbcType="INTEGER" />
    <result column="DEPT_NAME" property="deptName" jdbcType="VARCHAR" />
<id column="PERSON_ID" property="personId" jdbcType="INTEGER" />
    <result column="PERSON_NAME" property="personName" jdbcType="VARCHAR" />
  </resultMap>
  相关解决方案