命令行方式使用abator.jar生成ibatis相关代码和sql语句xml文件

2023-12-20 22:51:37

最近接手一个老项目,使用的是数据库是sql server 2008,框架是springmvc + spring + ibatis,老项目是使用abator插件生成的相关代码,现在需要增加新功能,要添加几张新表,可是目前网上下载的abator插件,在新版的eclippse中其UI根本打不开,所以只有使用命令行调用abator.jar来生成相关代码,将下载的abator插件解压出来,提取其中的abator.jar文件即可,其他的文件不需要。abator的配置文件如下:

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

27

28

29

30

31

32

33

34

35

36

37

38

39

40

<?xml version="1.0"?encoding="UTF-8"??>

<!DOCTYPE abatorConfiguration PUBLIC?"-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"?"http://ibatis.apache.org/dtd/abator-config_1_0.dtd">

<abatorConfiguration>

????<abatorContext>

????????<jdbcConnection driverClass="net.sourceforge.jtds.jdbc.Driver"??

????????????????????????connectionURL="jdbc:jtds:sqlserver://180.1xx.xx.121:1433/aazj"

????????????userId="mixxxer#$%"?password="fisuxxxxxx747">

????????????<classPathEntry location="D:/java_libs/repository/net/sourceforge/jtds/jtds/1.2.4/jtds-1.2.4.jar"?/>

????????</jdbcConnection>

????????<javaTypeResolver>

????????????<property name="forceBigDecimals"?value="false"?/>

????????</javaTypeResolver>

????????<javaModelGenerator targetPackage="net.minisns.dal.dataobject.model"

????????????????????????????targetProject="C:/minisns_new/src/main/java">

????????????<property name="enableSubPackages"?value="true"?/>

????????????<property name="trimStrings"?value="true"?/>

????????</javaModelGenerator>

????????<sqlMapGenerator targetPackage="sqlmap"?targetProject="C:/minisns_new/src/main/resources">

????????????<property name="enableSubPackages"?value="true"?/>

????????</sqlMapGenerator>

????????<daoGenerator type="SPRING"?targetPackage="net.minisns.dal.dao.model"

????????????????????????????????????targetProject="C:/minisns_new/src/main/java">

????????????<property name="enableSubPackages"?value="true"?/>

????????</daoGenerator>

?????????

????????<table tableName="model_entry">

????????????<property name="useActualColumnNames"?value="false"?/>

????????????<generatedKey column="id"?sqlStatement="sqlserver"?identity="true"?/>

????????</table>

????????<table tableName="model_recruiting_program">

????????????<property name="useActualColumnNames"?value="false"?/>

????????????<generatedKey column="id"?sqlStatement="sqlserver"?identity="true"?/>

????????</table>?????

????????<table tableName="model_choise">

????????????<property name="useActualColumnNames"?value="true"?/>

????????????<generatedKey column="id"?sqlStatement="sqlserver"?identity="true"?/>

????????</table>

????????<!---?? .....?? -->

????</abatorContext>

</abatorConfiguration>

?上面的配置中,<property name="useActualColumnNames" value="false" /> 该项比较重要,如果设置成true,那么生成的java类的属性和数据库字段是一致的,比如如果数据库字段带了下划线,那么java类中的属性,也会带下划线,所以我们一般将该项设置成false,这样的话,生成的代码才符合我们java中的规范。

下面是生成的命令行调用:

生成的代码如下:

实体类:

Dao接口及实现类:

sql文件:

文章来源:https://blog.csdn.net/omygodvv/article/details/135118339
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。