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>
<!-- 配置日志文件 -->
<settings>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
<!-- 配置别名,类多的话,配置包名也行 -->
<typeAliases>
<typeAlias type="com.zhaoyang.pojo.Students" alias="Students"/>
</typeAliases>
<!-- 配置连接池 -->
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</dataSource>
</environment>
</environments>
<!-- 配置Mapper文件,注意maper类和mapper.xml放在同一个文件夹中 -->
<mappers>
<package name="com.zhaoyang.mapper" />
</mappers>
</configuration>
mapper接口
传入对象,要加注解
List<Students> StudentsMoreWhere(@Param("Students") Students student);
mapper.xml中,此时我的parameterType和resultType已经用了别名了
<select id="StudentsMoreWhere" parameterType="Students" resultType="Students">
select * from Students where sAddr = #{Students.sAddr}
</select>