mybatis @Alias注解在类上的使用方式(推荐)

2025-05-29 0 56

比如在类上使用该注解 @alias("ddebtentity")

则在mapper.xml文件中resulttype="ddebtentity"

mybatisconfig.xml中

sqlsessionfactory需要配置注解 需要扫的路径

?

1

2

3
<typealiases>

<package name="com.xxxxx.core"/>

</typealiases>

mybatis之typealias配置的3种方法

1.定义别名:

?

1

2

3
<typealiases>

<typealias alias="user" type="cn.lxc.vo.user" />

</typealiases>

2.扫描包方式:

?

1

2

3
<typealiases>

<package name="cn.lxc.vo" />

</typealiases>

3.注解方式:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26
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;

}

}

总结

以上所述是小编给大家介绍的mybatis @alias注解在类上的使用方式,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对快网idc网站的支持!

原文链接:https://blog.csdn.net/qq_36838191/article/details/80346812

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 mybatis @Alias注解在类上的使用方式(推荐) https://www.kuaiidc.com/111791.html

相关文章

发表评论
暂无评论