type:指定要起别名的类型全类名,默认别名就是类名小写:
1 <typeAlias type="com.atguigu.mybatis.bean.Employee" alias="emp"/> -->为单个的java类起别名
2、package:为某个包下的所有类批量起别名
name :指定包名(为当前包以及下面所有的后代包的每一个类都起一个默认别名;别名默认是类名的首字母小写的形式)
1 <package name="com.atguigu.mybatis.bean"/>
3、批量起别名的情况下,使用@Alias注解为某个类型指定新的别名
1 @Alias("emp")
2 public class Employee {
4 private Integer id;
5 private String lastName;
6 private String email;
7 private String gender;
10 public Integer getId() {
11 return id;
12 }
13 public void setId(Integer id) {
14 this.id = id;
15 }
16 public String getLastName() {
17 return lastName;
18 }
19 public void setLastName(String lastName) {
20 this.lastName = lastName;
21 }
22 public String getEmail() {
23 return email;
24 }
25 public void setEmail(String email) {
26 this.email = email;
27 }
28 public String getGender() {
29 return gender;
30 }
31 public void setGender(String gender) {
32 this.gender = gender;
33 }
34 @Override
35 public String toString() {
36 return "Employee [id=" + id + ", lastName=" + lastName + ", email="
37 + email + ", gender=" + gender + "]";