MyBatis Generator的基础使用
2015-06-26 12:35
225 查看
参考自:MyBatis Generator
配置文件,参考官网的配置文件,增删若干,得出适合自己的配置
generatorConfig.xml
下载
MyBatis Generator包(mybatis-generator-core-1.3.2.jar)
MySQL的驱动包(mysql-connector-java-5.1.27.jar)
-
运用命令生成代码(此命令为覆盖原先的同名代码)
不想覆盖,则此命令
配置文件,参考官网的配置文件,增删若干,得出适合自己的配置
generatorConfig.xml
<?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> <!-- 数据库驱动包 --> <classPathEntry location="E:\j2ee_workspace\Mybatis_Generator\lib\mysql-connector-java-5.1.27.jar" /> <context id="MySQLTables" targetRuntime="MyBatis3"> <commentGenerator> <!-- 不需要注释 --> <property name="suppressAllComments" value="true"/> </commentGenerator> <!-- 数据库连接 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://xxx.xxx.xxx.xxx:xxxx/xxx" userId="xxx" password="password"> </jdbcConnection> <javaTypeResolver > <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 实体类 --> <javaModelGenerator targetPackage="com.nicchagil.model" targetProject="E:\j2ee_workspace\Mybatis_Generator\src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 映射关系、标准化的动态SQL文件 --> <sqlMapGenerator targetPackage="com.nicchagil.mapping" targetProject="E:\j2ee_workspace\Mybatis_Generator\src"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- DAO --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.nicchagil.dao" targetProject="E:\j2ee_workspace\Mybatis_Generator\src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 需转换的表,及相关配置。(默认生成全部标准动态SQL,这个将几个本人不用的设置为false,不生成。) --> <table tableName="T_USER" domainObjectName="User" enableSelectByExample="false" enableDeleteByExample="false" enableCountByExample="false" enableUpdateByExample="false" selectByExampleQueryId="false"> <!-- 使用驼峰式属性命名 --> <property name="useActualColumnNames" value="false"/> </table> </context> </generatorConfiguration>
下载
MyBatis Generator包(mybatis-generator-core-1.3.2.jar)
MySQL的驱动包(mysql-connector-java-5.1.27.jar)
-
运用命令生成代码(此命令为覆盖原先的同名代码)
java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite
不想覆盖,则此命令
java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml
相关文章推荐
- 异步流程控制:7 行代码学会 co 模块
- Powershell Profiles配置文件的存放位置介绍
- PowerShell入门教程之创建和使用配置文件实例
- SERV-U 的配置文件详解
- php.ini 配置文件的深入解析
- redis2.8配置文件中文翻译版
- PHP配置文件php.ini中打开错误报告的设置方法
- C#中读取App.config配置文件代码实例
- c++实现逐行读取配置文件写入内存的示例
- 关于session在PHP5的配置文件中的详细设置参数说明
- MySQL 配置文件my.cnf 例子最详细翻译
- apache 配置文件解说
- Ajax loading gif generator
- Android 读取Properties配置文件的小例子
- PHP 配置文件中open_basedir选项作用
- .net 读取非标准配置文件的小例子
- APACHE 配置文件中文版 httpd.conf FOR Apache 2.2.13
- 读取spring配置文件的方法(spring读取资源文件)
- PHPMyadmin 配置文件详解(配置)
- 浅析Mybatis 在CS程序中的应用