首先,先说一下写这个入门程序的需求与开发步骤:
那前三步就不说了有一些基础就可以办到
写入配置文件时,主要写入两种类型的配置文件。第一种类型是主配置文件,它管理与接口对应的其他配置文件。
[En]
When writing configuration files, two types of configuration files are mainly written. The first type is the main configuration file, which manages other configuration files corresponding to the interface.
在编写主配置文件时,主要有两点:
在编写映射配置文件的时候,文件名与Mapper接口(也可以说是Dao接口为持久层接口)名要一致(算是一种规范).通过命名空间来找到对应Mapper。
其对应id为其对应的方法,resultType为返回值类型。
mapper.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">