MyBatis逆向工程(generatorsqlmapcustom) 2016年11月26日 10:35:23

用generatorsqlmapcustom对数据库进行逆向工程,生成接口和xml,还有实体


1 首先下载generatorsqlmapcustom



2 导入工程




3 配置用户名密码




4 配置映射信息

[html]  view plain  copy
  1. <span style="font-size:24px;">  <?xml version="1.0" encoding="UTF-8"?>  
  2.     <!DOCTYPE generatorConfiguration  
  3.       PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"  
  4.       "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">  
  5.       
  6.     <generatorConfiguration>  
  7.         <context id="testTables" targetRuntime="MyBatis3">  
  8.             <commentGenerator>  
  9.                 <!-- 是否去除自动生成的注释 true:是 : false:否 -->  
  10.                 <property name="suppressAllComments" value="true" />  
  11.             </commentGenerator>  
  12.             <!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->  
  13.             <jdbcConnection driverClass="com.mysql.jdbc.Driver"  
  14.                 connectionURL="jdbc:mysql://localhost:3306/taotao" userId="root"  
  15.                 password="">  
  16.             </jdbcConnection>  
  17.             <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和   
  18.                 NUMERIC 类型解析为java.math.BigDecimal -->  
  19.             <javaTypeResolver>  
  20.                 <property name="forceBigDecimals" value="false" />  
  21.             </javaTypeResolver>  
  22.       
  23.             <!-- targetProject:生成PO类的位置 -->  
  24.             <javaModelGenerator targetPackage="com.taotao.pojo"  
  25.                 targetProject=".\src">  
  26.                 <!-- enableSubPackages:是否让schema作为包的后缀 -->  
  27.                 <property name="enableSubPackages" value="false" />  
  28.                 <!-- 从数据库返回的值被清理前后的空格 -->  
  29.                 <property name="trimStrings" value="true" />  
  30.             </javaModelGenerator>  
  31.             <!-- targetProject:mapper映射文件生成的位置 -->  
  32.             <sqlMapGenerator targetPackage="com.taotao.mapper"   
  33.                 targetProject=".\src">  
  34.                 <!-- enableSubPackages:是否让schema作为包的后缀 -->  
  35.                 <property name="enableSubPackages" value="false" />  
  36.             </sqlMapGenerator>  
  37.             <!-- targetPackage:mapper接口生成的位置 -->  
  38.             <javaClientGenerator type="XMLMAPPER"  
  39.                 targetPackage="com.taotao.mapper"   
  40.                 targetProject=".\src">  
  41.                 <!-- enableSubPackages:是否让schema作为包的后缀 -->  
  42.                 <property name="enableSubPackages" value="false" />  
  43.             </javaClientGenerator>  
  44.             <!-- 指定数据库表 -->  
  45.             <table schema="" tableName="tb_content"></table>  
  46.             <table schema="" tableName="tb_content_category"></table>  
  47.             <table schema="" tableName="tb_item"></table>  
  48.             <table schema="" tableName="tb_item_cat"></table>  
  49.             <table schema="" tableName="tb_item_desc"></table>  
  50.             <table schema="" tableName="tb_item_param"></table>  
  51.             <table schema="" tableName="tb_item_param_item"></table>  
  52.             <table schema="" tableName="tb_order"></table>  
  53.             <table schema="" tableName="tb_order_item"></table>  
  54.             <table schema="" tableName="tb_order_shipping"></table>  
  55.             <table schema="" tableName="tb_user"></table>  
  56.       
  57.         </context>  
  58.     </generatorConfiguration>  
  59.       
  60. </span>  


5 运行生成


猜你喜欢

转载自blog.csdn.net/qq_35232663/article/details/80709243
今日推荐