mybatis_generator自动生成 实体类,映射器,映射接口类
2014-03-27 17:59
501 查看
安装插件: help->install new sofeware 加入地址
name:generator
location:http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite
配置文件
generatorConfig.xml
说明:
生成实体类配置
生成mapper接口
数据库表配置
设置不生成Example类
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
name:generator
location:http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite
配置文件
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:/workspace2/SmartSign20140326/WebContent/WEB-INF/lib/mysql-connector-java-5.1.28-bin.jar" /> <context id="context" targetRuntime="MyBatis3"> <!-- 注释 --> <commentGenerator> <property name="suppressAllComments" value="true" /> <property name="suppressDate" value="true" /> </commentGenerator> <!-- 数据库连接 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/SmartRoad" userId="root" password="root" /> <!--允许数值类型转换成不同类型,否则都映射为BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 模型文件 --> <javaModelGenerator targetPackage="cn.tiger.smartsign.entity" targetProject="SmartSign20140326/src"> <property name="enableSubPackages" value="false" /> <!-- 当为true时,产生的代码文件将按照schema产生子文件夹 --> <property name="trimStrings" value="true" /> <!-- set变量时自动剔除空白 --> </javaModelGenerator> <!-- XML映射文件 --> <sqlMapGenerator targetPackage="cn.tiger.smartsign.xml" targetProject="SmartSign20140326/src"> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!-- DAO文件(mapper接口) --> <javaClientGenerator targetPackage="cn.tiger.smartsign.dao" targetProject="SmartSign20140326/src" type="XMLMAPPER"> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!-- 数据库表 --> <table schema="SmartRoad" tableName="users" domainObjectName="Users" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" > <property name="useActualColumnNames" value="false" /> </table> </context> </generatorConfiguration>
说明:
生成实体类配置
<!-- 模型文件 --> <javaModelGenerator targetPackage="cn.tiger.smartsign.entity" targetProject="SmartSign20140326/src"> <property name="enableSubPackages" value="false" /> <!-- 当为true时,产生的代码文件将按照schema产生子文件夹 --> <property name="trimStrings" value="true" /> <!-- set变量时自动剔除空白 --> </javaModelGenerator>生成映射器xml文件配置
<!-- 模型文件 --> <javaModelGenerator targetPackage="cn.tiger.smartsign.entity" targetProject="SmartSign20140326/src"> <property name="enableSubPackages" value="false" /> <!-- 当为true时,产生的代码文件将按照schema产生子文件夹 --> <property name="trimStrings" value="true" /> <!-- set变量时自动剔除空白 --> </javaModelGenerator>
生成mapper接口
<!-- XML映射文件 --> <sqlMapGenerator targetPackage="cn.tiger.smartsign.xml" targetProject="SmartSign20140326/src"> <property name="enableSubPackages" value="false" /> </sqlMapGenerator>
数据库表配置
<!-- 数据库表 --> <table schema="SmartRoad" tableName="users" domainObjectName="Users" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" > <property name="useActualColumnNames" value="false" /> </table>
设置不生成Example类
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
相关文章推荐
- 如何用MyBatis-Generator自动创建代码(映射生成实体类、DAO接口和Mapping映射文件)
- 使用mybatis-generator自动生成实体类,接口实现类和Mapper映射配置文件
- 使用Mybatis生成工具自动生成实体类和对应的mapper映射文件以及接口文件
- MyBatis自动生成实体类、DAO接口和Mapping映射文件的代码(逆向工程)
- Mybatis自动生成实体类,映射文件,以及dao层接口。
- SSM框架搭建(三) 数据库创建和MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
- 利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
- 使用Mybatis-Generator自动生成entity实体、dao接口以及mapper映射文件
- 整合maven+mybatis+generator生成java自定义model实体类,dao接口和mapper映射文件
- 简单两步快速学会使用Mybatis-Generator自动生成entity实体、dao接口和简单mapper映射(用mysql和oracle举例)
- 简单三步快速学会使用Mybatis-Generator自动生成entity实体、dao接口以及mapper映射文件(postgre使用实例)
- mybatis逆向工程自动生成实体类、接口以及映射Mapper.xml配置文件
- mybatis自动生成映射文件实体类接口
- Mybatis--使用mybatis generator插件映射数据库,自动生成pojo对象,dao接口,mapper.xml文件的方法
- 使用generator自动生成Mybatis映射配置文件
- Mybatis使用generator自动生成映射配置文件信息
- 命令+mybatis-generator插件自动生成Mapper映射文件
- Mybatis使用generator自动生成映射配置文件信息
- Mybatis使用generator自动生成映射配置文件信息
- 在IDEA下,使用maven的mybatis-generator-maven-plugin插件自动生成实体类