标签:mes exce 用户 sys asd word Nid import junit
<?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">
?
<!--mybatis的主配置文件-->
<configuration>
?
<properties resource="jdbcConfig.properties"/>
?
<!--配置别名-->
<typeAliases>
<package name="com.itheima.domain" ></package>
</typeAliases>
?
<!--配置环境-->
<environments default="mysql">
<!--配置mysql的环境-->
<environment id="mysql">
<!--配置事务的类型-->
<transactionManager type="JDBC"></transactionManager>
<!--配置数据源(连接池)-->
<dataSource type="POOLED">
<!--配置数据库的四个基本信息-->
<property name="driver" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</dataSource>
</environment>
</environments>
?
<!--指定映射配置文件的位置,映射配置文件指的是每个dao独立的配置文件-->
<mappers>
<package name="com.itheima.dao"></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.dao.IUserDao">
<!--配置查询所有-->
<!-- resultType:返回值要封装的全限定类名
parameterType:传递自定义参数时,写入参数的全限定类名
传递基本类型时,写入java.lang.Integer/INT/Integer都可以
-->
?
<!--抽取重复的sql代码-->
<sql id="asdfgh" >
select * from user;
</sql>
?
<select id="findAll" resultType="user">
<include refid="asdfgh"></include>
<!-- select * from user; -->
</select>
?
?
<!--根据id查找一个用户的信息-->
<select id="findById" parameterType="INT" resultType="user">
select * from user where id = #{userid}
</select>
?
<!--根据名称模糊查询-->
<select id="findByName" parameterType="string" resultType="com.itheima.domain.User">
select * from user where username like #{name}
/* select * from user where username like ‘%${value}%‘ */
</select>
?
<!--根据QueryVo的条件查询用户-->
<select id="findUserByVo" parameterType="com.itheima.domain.QueryVo" resultType="com.itheima.domain.User">
select * from user where username like #{user.username}
</select>
?
<!--根据条件查询-->
<select id="findUserByCondition" resultType="com.itheima.domain.User" parameterType="user">
select * from user
<where>
<if test="username != null">
and username = #{username}