<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-config.dtd"><configuration><environmentsdefault="development"><environmentid="development"><transactionManagertype="JDBC"/><dataSourcetype="POOLED"><propertyname="driver"value="org.h2.Driver"/><propertyname="url"value="jdbc:h2:~/cherry;AUTO_SERVER=true"/><propertyname="username"value="sa"/><propertyname="password"value="sa"/></dataSource></environment></environments><mappers><mapperresource="org/example/BlogMapper.xml"/></mappers></configuration>
配置BlogMapper.xml 於專案中,此Xml用以儲存SQL語句
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd"><mappernamespace="BlogMapper"><selectid="selectBlog"resultType="Blog">
select * from Blog where id = #{id}
</select></mapper>