简介
对应配置文件中的typeAliases
标签。当类的全限定名过长时,我们可以用一个简称指代它,这个简称可以在上下文中使用。
不区分大小写。
分类
分为两种:系统定义别名
和自定义别名。
系统定义别名
别名 | 映射的类型 |
---|---|
_byte | byte |
_long | long |
_short | short |
_int | int |
_integer | int |
_double | double |
_float | float |
_boolean | boolean |
string | String |
byte | Byte |
long | Long |
short | Short |
int | Integer |
integer | Integer |
double | Double |
float | Float |
boolean | Boolean |
date | Date |
decimal | BigDecimal |
bigdecimal | BigDecimal |
object | Object |
map | Map |
hashmap | HashMap |
list | List |
arraylist | ArrayList |
collection | Collection |
iterator | Iterator |
自定义别名
方式1:
<typeAliases>
<typeAlias alias="user" type="mncode.entity.User"></typeAlias>
</typeAliases>
方式2:
扫描指定包,并在类上使用注解@Alias指定别名:
<typeAliases>
<package name="mncode.entity"/>
</typeAliases>
@Alias("user")
public class User {
}