mybatis_5_创建mapper.xml
创建mapper.xml
示例IndicatorMapper.xml:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="tk.mybatis.simple.mapper.IndicatorMapper"> <select id="indicatorName" resultType="tk.mybatis.simple.mapper.Indicator"> select indicator_name as indicatorName from test_table where indicator_code = #{indicatorCode} </select> </mapper>
分析:
namespace为mapper.xml文件的路径
resultType为返回类型,当前示例中返回的类型为JavaBean
文件结构: