IBatisNet的配置文件的格式采用了标准的XML的命名空间,如果没有相应的命名空间定义,系统在载入配置文件时会因为验证通不过而出错:
原来的providers.config 文件
<?xml version="1.0" encoding="utf-8" ?>
原来的providers.config 文件
<?xml version="1.0" encoding="utf-8" ?>
<providers>
<clear/>
<provider
……
</providers>
更改为
<?xml version="1.0" encoding="utf-8"?>
<providers xmlns="http://ibatis.apache.org/providers" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<clear/>
<provider
……
</providers>
原来的SqlMap.config文件
<clear/>
<provider
……
</providers>
更改为
<?xml version="1.0" encoding="utf-8"?>
<providers xmlns="http://ibatis.apache.org/providers" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<clear/>
<provider
……
</providers>
原来的SqlMap.config文件
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd">
……
</sqlMapConfig>
更改为
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
原来的PO.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMapConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd">
……
</sqlMapConfig>
更改为
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
原来的PO.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="Sequence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="SqlMap.xsd">
……
</sqlMap>
更改为
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="Admin" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
……
</sqlMap>
xsi:noNamespaceSchemaLocation="SqlMap.xsd">
……
</sqlMap>
更改为
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="Admin" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
……
</sqlMap>
为了让Vs2005 帮助验证配置文件的正确性,在编写配置文件时提供帮助,需要把SqlMap.xsd,SqlMapConfig.xsd,provider.xsd拷贝到C:/Program Files/Microsoft Visual Studio 8/Xml/Schemas下