MyBatis xml配置typeAliases
typeAliases一般配置在实体类的xml配置文件中
typeAliases
类型别名是为 Java 类型命名一个短的名字。 它只和 XML 配置有关, 只用来减少类完全 限定名的多余部分。例如:
<typeAliases> <typeAlias alias="Author" type="domain.blog.Author"/> <typeAlias alias="Blog" type="domain.blog.Blog"/> <typeAlias alias="Comment" type="domain.blog.Comment"/> <typeAlias alias="Post" type="domain.blog.Post"/> <typeAlias alias="Section" type="domain.blog.Section"/> <typeAlias alias="Tag" type="domain.blog.Tag"/> </typeAliases>
使用这个配置, “Blog”可以任意用来替代“domain.blog. Blog”所使用的地方。
You can also specify a package where MyBatis will search for beans. For example:
也可以配置包
<typeAliases> <package name="domain.blog"/> </typeAliases>
Each bean found in domain.blog , if no annotation is found, will be registered as an alias using uncapitalized non-qualified class name of the bean. Thas is domain.blog.Author will be registered as Author . If the @Alias annotation is found its value will be used as an alias. See the example below:
@Alias("author")
public class Author {
...
}
浙公网安备 33010602011771号