zoukankan      html  css  js  c++  java
  • Result Maps collection already contains value for com.cq.zys.dao.StudentMapper.BaseResultMap

    在ssm整合时,因为是自动生成的代码,后来因为手贱把一个实体类删了,忘记把mapper一起删就开始重新生成实体了

    结果报错:nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentMapper' defined in file [D: ekoworkspacessmAngular argetclassescomcqzysdaoStudentMapper.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 [D: ekoworkspacessmAngular argetclassescomcqzysmappingStudentMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause:  Result Maps collection already contains value for com.cq.zys.dao.StudentMapper.BaseResultMap

    后来找了很久突然发现mapper.xml居然出现了追加部分,即:

    <id column="emp_id" jdbcType="BIGINT" property="emp_id" />
        <result column="work_number" jdbcType="VARCHAR" property="work_number" />
        <result column="role_id" jdbcType="INTEGER" property="role_id" />
        <result column="photo" jdbcType="VARCHAR" property="photo" />
        <result column="name" jdbcType="VARCHAR" property="name" />
        <result column="gender" jdbcType="VARCHAR" property="gender" />
        <result column="telephone" jdbcType="VARCHAR" property="telephone" />
        <result column="max_advisory" jdbcType="INTEGER" property="max_advisory" />
        <result column="introduction" jdbcType="VARCHAR" property="introduction" />
        <result column="state" jdbcType="VARCHAR" property="state" />
        <result column="create_time" jdbcType="TIMESTAMP" property="create_time" />
      </resultMap>这个都出现了三遍,刚好是我重新生成代码的次数,所以原因出来了:

    原因:每次自动生成代码前,要把之前已有的mapper.xml和java类一起删了,不然每次自动生成时,

    会在已有的xml文件上追加新增部分,不会覆盖而是追加,不是覆盖,不是覆盖,把重复部分删了就解决了

  • 相关阅读:
    最大值及下标值
    查找整数
    打印沙漏
    抓老鼠啊~亏了还是赚了?
    币值转换
    秋季学期学习总结
    菜鸟学习Spring——SpringIoC容器基于三种配置的对比
    yanxin8文章归档
    2014——2015总结
    Java入门到精通——调错篇之Spring2.5利用aspect实现AOP时报错: error at ::0 can't find referenced pointcut XXX
  • 原文地址:https://www.cnblogs.com/crazy-yyl/p/7309759.html
Copyright © 2011-2022 走看看