起别名 ,,存在的意义仅在于用来减少类完全限定名的冗余。
mybatis-config.xml
</properties>
<typeAliases>
<typeAlias type="com.kuang.pojo.User" alias="User"/> <!--第一种别名方式-->
</typeAliases>
</properties>
<typeAliases>
<package name="com.kuang.pojo"/> <!--第二种别名方式-->
</typeAliases>
UserMapper.xml
<select id="getUserList" resultType="user"> <=这里的user,本来是com.kuang.pojo.User
select * from mybatis.user
</select>
在实体类比较少的时候,使用第一种方式。
如果实体类十分多,建议使用第二种。
第一种可以DIY别名,第二种则·不行·,如果非要改,需要在实体上增加注解
User.java 接口文件
@Alias("hello")
public class User {