[英]Error Message When Running MyBatis at the first time
I have a strange problem when running my application in JBOSS at the first time: The error message is: 我第一次在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)
Mapper File: project.services.dao.sql.workerDAO.xml 映射文件: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>
However, for the second time, there is no Error Message. 但是,第二次没有错误消息。 Any help will be appreciated.
任何帮助将不胜感激。 Thanks all.
谢谢大家。
I had the same trouble, and finally I find the reason is that there are repetitional sql id in mapping xml file. 我遇到了同样的麻烦,最后我发现原因是在映射xml文件时有重复的sql id。
I hope this is helpful to you. 我希望这对你有所帮助。
It seems like a bug in MyBatis. 这似乎是MyBatis中的一个错误。 The java class
workerDAO
can't take the same name as a mapper workerDAO.xml
. java类
workerDAO
不能与mapper workerDAO.xml
具有相同的名称。 So, try to change the mapper to workerMapper.xml
then test. 因此,尝试将mapper更改为
workerMapper.xml
然后进行测试。 Please read this article for more information. 请阅读本文以获取更多信息。 I hope it's helpful.
我希望它有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.