MyBatis代码生成工具mybatis-generator在Myeclipse2014中的使用
2015-12-29 15:51
731 查看
一、在MyEclipse安装目录下新建MyPlugin目录,如下图所示:
二、将 mybatis.zip 里面的文件放在MyEclipse的dropins目录下,如下图所示:
三、在Myeclipse安装目录dropins下,新建mybatis.link文件,并在文件中指明mybatis-generator放置的路径:
四、将Mybatis需要的 mysql-connector-java-5.1.23.jar 等jar包引入项目;
[b]五、在项目中放入generatorConfig.xml 文件并做相应修改:[/b]
generatorConfig.properties文件
六、重启Myeclipse,鼠标右击generatorConfig.xml 文件,在弹出的菜单中选择Generate MyBatis/iBATIS Artifacts 即可生成所需文件:
二、将 mybatis.zip 里面的文件放在MyEclipse的dropins目录下,如下图所示:
三、在Myeclipse安装目录dropins下,新建mybatis.link文件,并在文件中指明mybatis-generator放置的路径:
四、将Mybatis需要的 mysql-connector-java-5.1.23.jar 等jar包引入项目;
[b]五、在项目中放入generatorConfig.xml 文件并做相应修改:[/b]
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > <generatorConfiguration> <properties resource="generatorConfig.properties" /> <context id="context1" targetRuntime="MyBatis3" defaultModelType="flat"> <plugin type="org.mybatis.generator.plugins.RowBoundsPlugin"></plugin> <plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <jdbcConnection driverClass="${driverClass}" connectionURL="${connectionURL}" userId="${user}" password="${password}" /> <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <javaModelGenerator targetPackage="${modelPackage}" targetProject="a-base\src\main\java"> <property name="trimStrings" value="true" /> </javaModelGenerator> <sqlMapGenerator targetPackage="${sqlMapperPackage}" targetProject="a-base\src\main\java" /> <javaClientGenerator targetPackage="${daoMapperPackage}" targetProject="a-base\src\main\java" type="XMLMAPPER" /> <table tableName="account_phone" domainObjectName="AccountPhone" ></table> <!--<table tableName="app_version" domainObjectName="AppVersion" ><columnOverride column="content" jdbcType="VARCHAR"/> </table> <table tableName="deposit" domainObjectName="Deposit" ><columnOverride column="bank_ret" jdbcType="VARCHAR"/> </table> --> <!--<table tableName="order_id_gen" domainObjectName="OrderIdGen" ></table> --> <!--<table tableName="withdraw" domainObjectName="Withdraw"></table>--> <!-- <table tableName="user_bank" domainObjectName="UserBank" ></table> --> <!--<table tableName="cash_log" domainObjectName="CashLog" ></table> --> <!-- <table tableName="project" domainObjectName="Project" ></table> --> <!-- <table tableName="project_daily" domainObjectName="ProjectDaily" ></table> <table tableName="project_manhour" domainObjectName="ProjectManhour" ></table> --> <!--<table tableName="project_member" domainObjectName="ProjectMember"></table> --> <!--<table tableName="sys_resource" domainObjectName="SysResource" ></table> <table tableName="sys_role" domainObjectName="SysRole" ></table> <table tableName="sys_user" domainObjectName="SysUser" ></table> --> <!-- <table tableName="transfer_item" domainObjectName="TransferItem" ></table> --> <!--<table tableName="transfer_order" domainObjectName="TransferOrder" ></table> --> <!--<table tableName="apply_user" domainObjectName="ApplyUser" ></table> --> <!--<table tableName="user" domainObjectName="User" ></table> --> <!--<table tableName="account" domainObjectName="Account" ></table> --> <!--<table tableName="user_login_log" domainObjectName="UserLoginLog" ></table> <table tableName="user_log" domainObjectName="UserLog" ></table> --> <!--<table tableName="api" ></table> <table tableName="api_module"></table> --> <!--<table tableName="api_param"></table> <table tableName="api_retparam"></table> --> </context> </generatorConfiguration>
generatorConfig.properties文件
driverClass=com.mysql.jdbc.Driver connectionURL=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF8 user=root password=123456 modelPackage=brant.base.domain sqlMapperPackage=brant.base.persistence daoMapperPackage=brant.base.persistence
六、重启Myeclipse,鼠标右击generatorConfig.xml 文件,在弹出的菜单中选择Generate MyBatis/iBATIS Artifacts 即可生成所需文件:
相关文章推荐
- eclipse maven学习记录
- 安卓向服务器(Spring)发送json
- Spring - 动态代理 与 AOP 理解
- 【Struts2基础知识】
- 遇到的问题---springMVC中ajax数组传值报400或者415错误
- 遇到的问题---springMVC中ajax数组传值报400或者415错误
- myeclipse中的js文件报错
- MyEclipse那些事
- Java中的23种设计模式
- java设计6大设计原则
- 从头认识java-15.5 使用LinkedHashSet需要注意的地方
- 获取当前时间所在凌晨和23:59:59
- JAVA正则表达式:Pattern类与Matcher类详解(转)
- java发送邮件没有主题且乱码以及如何exclusion依赖
- 初学Java,第一段代码
- eclipse svn状态图标 等等都不见了。
- Spring forward 和 redirect
- EGit插件安装(附Eclipse版本对应表)
- java.lang.NoClassDefFoundError:/javax/transaction/SystemException错误解决方法
- Java代码生成器