在eclipse中发布我的项目时,出现错误,表明我的映射器已经存在

时间:2018-11-16 02:02:09

标签: java spring-mybatis

  

这是我的错误:

Nov 16, 2018 9:27:00 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ictinvMapper' defined in file [C:\Users\Ricardo\workspace3\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\INTRANET4B\WEB-INF\classes\doh\ro4b\intranet4b\persistence\IctinvMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for doh.ro4b.intranet4b.persistence.IctinvMapper.getIctinvList
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for doh.ro4b.intranet4b.persistence.IctinvMapper.getIctinvList
    at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:84)
    at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    ... 21 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for doh.ro4b.intranet4b.persistence.IctinvMapper.getIctinvList
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92)
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:167)
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:118)
    at org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:72)
    at org.apache.ibatis.session.Configuration.addMapper(Configuration.java:671)
    at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:81)
    ... 24 more
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for doh.ro4b.intranet4b.persistence.IctinvMapper.getIctinvList
    at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:802)
    at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:774)
    at org.apache.ibatis.session.Configuration.addMappedStatement(Configuration.java:598)
    at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:300)
    at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:109)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:135)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
    ... 30 more
  

这是我的界面:   通常xml和界面中的ID是相同的。

package doh.ro4b.intranet4b.persistence;

import java.util.List;

import doh.ro4b.intranet4b.domain.Ictinv;

public interface IctinvMapper {

    public List<Ictinv> getIctinvList (Ictinv ictinv);

    public int getTotalRowCountIctinv ();

    public void addIctinv (Ictinv ictinv);

    public Ictinv viewIctinv (int ictinv_seqno);

    public int modifyIctinv (Ictinv ictinv);

    public int deleteIctinv (int ictinv_seqno);

}
  

这是我的xml映射器:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="doh.ro4b.intranet4b.persistence.IctinvMapper">

    <select id="getIctinvList" parameterType="Ictinv" resultType="Ictinv">
        SELECT *
        FROM tbl_ictinv
        ORDER BY ictinv_seqno ASC
        <!-- LIMIT #{startRowNo}, #{rowCountPerPage} -->
    </select>

    <select id="getTotalRowCountIctinv" parameterType="Ictinv"
        resultType="int">
        SELECT COUNT(ictinv_seqno)
        FROM tbl_ictinv
    </select>
  

如果我删除插入和更新标签,则不会出现错误   请注意,我没有使用相同的ID名称

    <insert id="addIctinv" parameterType="Ictinv">
        INSERT INTO 
        tbl_ictinv
        (ictinv_seqno,
        eqdetail_seqno,
        ictinv_macaddr,
        ictinv_year,
        ictinv_propno,
        ictinv_unitval,
        equom_seqno,
        ictinv_qtypropcard,
        ictinv_qtyphyscount,
        ictinv_respname,
        ictinv_assignname,
        eqstat_seqno,
        ictinv_acccode,
        ictinv_audit,
        ictinv_date)

        VALUES (#{ictinv_seqno},
        #{eqdetail_seqno},
        #{ictinv_macaddr},
        #{ictinv_year},
        #{ictinv_propno},
        #{ictinv_unitval},
        #{equom_seqno},
        #{ictinv_qtypropcard},
        #{ictinv_qtyphyscount},
        #{ictinv_respname},
        #{ictinv_assignname},
        #{eqstat_seqno},
        #{ictinv_acccode},
        #{ictinv_audit},
        #{ictinv_date})
    </insert>

    <select id="viewIctinv" parameterType="int" resultType="Ictinv">
        SELECT *
        FROM tbl_ictinv
        WHERE ictinv_seqno = #{ictinv_seqno}
    </select>

    <update id="modifyIctinv" parameterType="Ictinv">
        UPDATE 
        tbl_ictinv
        SET
        ictinv_seqno = #{ictinv_seqno},
        eqdetail_seqno = #{eqdetail_seqno},
        ictinv_macaddr = #{ictinv_macaddr},
        ictinv_year = #{ictinv_year},
        ictinv_propno = #{ictinv_propno},
        ictinv_unitval = #{ictinv_unitval},
        equom_seqno = #{equom_seqno},
        ictinv_qtypropcard = #{ictinv_qtypropcard},
        ictinv_qtyphyscount = #{ictinv_qtyphyscount},
        ictinv_respname = #{ictinv_respname},
        ictinv_assignname = #{ictinv_assignname},
        eqstat_seqno = #{eqstat_seqno},
        ictinv_acccode = #{ictinv_acccode},
        ictinv_audit = #{ictinv_audit},
        ictinv_date = #{ictinv_date}
        WHERE ictinv_seqno = #{ictinv_seqno}
    </update>

    <delete id="deleteIctinv" parameterType="Ictinv">
        DELETE
        FROM tbl_ictinv
        WHERE ictinv_seqno = #{ictinv_seqno}
    </delete>
</mapper>
  

注意:如果删除插入和更新标签,则没有错误。最好的解决方案是什么?

0 个答案:

没有答案