1

第一次在JBOSS中运行我的应用程序时遇到一个奇怪的问题:错误信息是:

javax.servlet.ServletException: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for project.services.dao.workerDAO.getAllWorkers
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

映射器文件:project.services.dao.sql.workerDAO.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="project.services.dao.workerDAO">

    <select id="getAllWorkers" parameterType="java.lang.String"
        resultType="Worker">

         Select wrk.Id As workerId, wrk.Nm As workerName
         From Worker wrk

    </select>

</mapper>

但是,第二次没有错误消息。

4

2 回答 2

3

我遇到了同样的麻烦,最后我发现原因是映射xml文件中有重复的SQL id。

于 2015-03-20T09:58:59.530 回答
0

这似乎是 MyBatis 中的一个错误。java 类workerDAO不能与 mapper 同名workerDAO.xml。因此,尝试更改映射器以workerMapper.xml进行测试。请阅读这篇文章以获取更多信息。我希望它会有所帮助。

于 2013-03-25T18:34:03.773 回答