For example, use this annotation @Alias("dDebtEntity") on the class
Then resultType="dDebtEntity" in the mapper.xml file
In myBatisConfig.xml
sqlSessionFactory needs to configure the path to scan the annotation
<typeAliases><package name="com.xxxxx.core"/></typeAliases>
3 ways to configure Mybatis typeAlias
1. Define the alias:
<typeAliases> <typeAlias alias="User" type="cn.lxc.vo.User" /></typeAliases>
2. Scan package method:
<typeAliases> <package name="cn.lxc.vo" /></typeAliases>
3. Annotation method:
package cn.lxc.vo;import org.apache.ibatis.type.Alias;@Alias("User")public class User { private int id; private String name; private int age; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; }}Summarize
The above is the use of mybatis @Alias annotation on the class introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!