method one
<!--可以给实体类起别名-->
<typeAliases>
<typeAlias type="com.tt.pojo.User" alias="User"/>
</typeAliases>
Method Two
You can also specify a package name, MyBatis will search package name below the required Java Bean, such as:
Scanning entity class package, his default alias for the class name of the class, the first letter lowercase!
<!--可以给实体类起别名-->
<typeAliases>
<package name="com.tt.pojo"/>
</typeAliases>
In analogy entity less when using the first embodiment.
If the entity classes very much, recommended the second approach.
The first alias can be customized, and the second is not, have to change if necessary to increase @Alias annotation on the entity class (POJO)
@Alias("author")
public class Author {
...
}
Since significance alias
- Type an alias for Java type is set a short name.
- Only in the meaning of existence for reducing redundancy of fully qualified names.