June 28, 2010

MyBatis 3.0 XML Headers

Since everyone always forgets these, here are the MyBatis 3.0.x dtd headers that you should put at the top of your mybatis xml files.

The main mybatis configuration file:
projectname/src/mybatis.config.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 
 "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
...
</configuration>

Any mybatis mapper file:
projectname/src/com/package/MyMapper.xml



<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper>
...
</mapper>