错误:Element type "select" must be declared.

      在刚刚学习ibatis时,使用的jar包是ibatis-sqlmap-2.3.4.726-sources.jar,一运行就碰到了异常:Element type "select" must be declared.网上查了好久也没有找到是什么原因造成的,后来自己从网上下载了一个ibatis-2.3.4.726.zip查看里面的例子,一对照自己的配置就发现了问题所在是因为我违背了DTD的声明格式。

  我的ibaties的DTD格式是:

  1、sql-map-config.xml中的DTD格式

  sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
    "http://www.ibatis.com/dtd/sql-map-config-2.dtd">

改成:

sqlMapConfig      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

  2、Student.xml中的DTD格式

  sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
    "http://www.ibatis.com/dtd/sql-map-config-2.dtd">

 改成:

 sqlMap      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">

改完之后就可以运行了。

你可能感兴趣的:(Ibatis)