ibatis问题求助
public List<Sex> getAll(){ List<Sex> sexs = new ArrayList<Sex>(); try { Map map = new HashMap(); sexs = SqlMapUtil.sqlMapClient.queryForList("Sex.getAll", map); } catch (SQLException e) { e.printStackTrace(); } return sexs; }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <sqlMap namespace="Sex"> <typeAlias alias="sex" type="db.pojo.Sex" /> <select id="getAll" parameterClass="java.util.Map" resultClass="sex"> <![CDATA[ SELECT id, name FROM sex ]]> </select> </sqlMap>
数据库
出现异常
Exception in thread "main" java.lang.ExceptionInInitializerError
at db.imp.SexImp.getAll(SexImp.java:19)
at db.Test.main(Test.java:9)
Caused by: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: java.io.IOException: Could not find resource db/xml/Config.xml
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at db.SqlMapUtil.<clinit>(SqlMapUtil.java:16)
... 2 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: java.io.IOException: Could not find resource db/xml/Config.xml
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
... 4 more
Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: java.io.IOException: Could not find resource db/xml/Config.xml
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)
... 5 more
Caused by: java.io.IOException: Could not find resource db/xml/Config.xml
at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:110)
at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:95)
at com.ibatis.common.resources.Resources.getResourceAsReader(Resources.java:161)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:262)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
... 9 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
怎么没人啊
找到问题了 重新生成了另一个库 忘记改SqlMapConfig配置文件了 谢谢你们帮助
java.io.IOException: Could not find resource db/xml/Config.xml
你这个Config.xml的文件注册到总的配置文件里了吗?
找到问题了 重新生成了另一个库 忘记改SqlMapConfig配置文件了 谢谢你们帮助