MyBtis配置文件之typeAliases元素

1、MyBatis自定义别名

1.1配置文件配置别名

<typeAliases>
    <typeAlias type="com.shop.Role" alias="role"/>
</typeAliases>

1.2批量配置别名

先定义扫描的包
<typeAliases>
    <package name="com.shop"/>
</typeAliases>

使用注解为类设置别名,当不使用注解的时候,默认类名首字母小写作为别名
@Alias(“role”)
public class Role {
}

2、MyBatis支持的别名

别名 映射的类型
_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

猜你喜欢

转载自blog.csdn.net/newbie_907486852/article/details/80270284