使用ibatis时遇到Error parsing XPath '/sqlMapConfig/sqlMap'低级错误
程序员文章站
2022-04-26 12:07:36
...
使用ibatis时,遇到一错误。是疏忽造成的,留作记录。
错误信息如下:
RROR Plat.Ser: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.lang.RuntimeException: Could not find SQL statement to include with refid 'Insert_column' java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.lang.RuntimeException: Could not find SQL statement to include with refid 'Insert_column' at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:89)
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.lang.RuntimeException: Could not find SQL statement to include with refid 'Insert_column' at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86) ... 27 more Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.lang.RuntimeException: Could not find SQL statement to include with refid 'Insert_column' at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) ... 28 more Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.lang.RuntimeException: Could not find SQL statement to include with refid 'Insert_column' at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53) at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:51) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$11.process(SqlMapConfigParser.java:410) at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121) ... 32 more Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.lang.RuntimeException: Could not find SQL statement to include with refid 'Insert_column' at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) ... 35 more Caused by: java.lang.RuntimeException: Could not find SQL statement to include with refid 'Insert_column' at com.ibatis.sqlmap.engine.builder.xml.SqlStatementParser.parseDynamicTags(SqlStatementParser.java:255) at com.ibatis.sqlmap.engine.builder.xml.SqlStatementParser.processSqlStatement(SqlStatementParser.java:204) at com.ibatis.sqlmap.engine.builder.xml.SqlStatementParser.parseGeneralStatement(SqlStatementParser.java:120) at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser$19.process(SqlMapParser.java:563) at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121) ... 39 more
代码如下:
<insert id="Insert" parameterClass="uecpSplitOrder"> insert into umpay.$tableName$( <include refid="Insert_column" /> ) values ( <include refid="Insert_value" /> ) </insert> <sql id="Insert_column"> ................................ </sql> <sql id="Insert_value"> ................................. </sql>
相信睿智的各位都已经发现了问题。没错,引用者放在了被引用者的前面,ibatis解析的时候找不到refid的对象,从而导致出错。