iBatis的代码生成工具

iBatis的代码自动生成工具abator
今天试了以下,感觉挺不错的
首先下载eclipse 的插件
Helo => Software Updates => Find and Install   => Search for new features to insall
=> Next => New Remote Site
在弹出的对话框中输入
http://ibatis.apache.org/tools/abator
Ok!
勾选abator 点击 Finish! 自动安装

在 project 上点击右键 New =》 other 选择 Abator for iBATIS Wizared下的 Abator for iBATIS Configuration File

在你的project 目录下生成以个abatorConfig.xml文件

<?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="???" connectionURL="???" userId="???" password="???" >
      <classPathEntry location="???" />
    </jdbcConnection>
    <javaModelGenerator targetPackage="???" targetProject="???" />
    <sqlMapGenerator targetPackage="???" targetProject="???" />
    <daoGenerator targetPackage="???" targetProject="???" type="GENERIC-CI" />
    <table schema="???" tableName="???" >
      <columnOverride column="???" property="???" />
    </table>
  </abatorContext>
</abatorConfiguration>


替换文件中的 ???
driverClass: jdbc驱动  com.mysql.jdbc.Driver
connectionURL 连接数据库的url  jdbc:mysql://localhost:3306/security
userId 用户名
password :密码
classPathEntry:jdbc驱动jar包的位置 D:\Projects\ui2\Security\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.6-bin.jar

javaModelGenerator
      targetPackage java model的包名  com.unimas.bean
      targetProject 项目名
sqlMapGenerator
      targetPackage  生成sqlmap的所在包名
      targetProject 项目名
daoGenerator  生成的DAO
      targetPackage  生成dao的包名
table  tableName 表名
<columnOverride column="???" property="???" /> 可以不写 ,删掉或注释掉

<?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="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/security" userId="root" password="123456" >
      <classPathEntry location="D:\Projects\ui2\Security\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.6-bin.jar" />
    </jdbcConnection>
    <!--targetPackage指定一个包名存放model bean,targetProject是工程名-->
    <javaModelGenerator targetPackage="com.unimas.bean" targetProject="Security" />
    <sqlMapGenerator targetPackage="com.unimas.bean.mapping" targetProject="Security" />
    <daoGenerator targetPackage="com.unimas.dao" targetProject="Security" type="SPRING" />
    <table tableName="t_user" >
     
    </table>
  </abatorContext>
</abatorConfiguration>


在配置文件上点解右键,选择 “Generate iBatis Artifacts”

你可能感兴趣的:(DAO,apache,mysql,ibatis,jdbc)