核心配置文件 <?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> <!--定义别名--> <typeAliases> <!--<typeAlias type="com.itheima.domin.Account" alias="account"></typeAlias>--> <package name="com.itheima.domin"></package> </typeAliases> <!--<!–加载映射关系,使用注解所需要的的–> <mappers> <!–指定接口所在的包–> <package name="com.itheima.mapper"></package> </mappers>--> </configuration>
映射文件
<?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="com.itheima.mapper.AccountMapper"> <insert id="save" parameterType="account"> insert into account values(#{id},#{name},#{money}) </insert> <select id="findAll" resultType="account"> select * from account </select> </mapper>