ITPub博客

首页 > 应用开发 > IT综合 > mybatis 自动生成xml、model、Mapper 代码

mybatis 自动生成xml、model、Mapper 代码

原创 IT综合 作者:saintlu 时间:2014-07-26 10:43:45 0 删除 编辑
config.xml文件

点击(此处)折叠或打开

  1. <?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. <generatorConfiguration>
  6.   <classPathEntry location=\"jtds-1.2.2.jar\" />

  7.   <context id=\"Mssql2Tables\" targetRuntime=\"MyBatis3\">
  8.     <commentGenerator>
  9.         <property name=\"suppressDate\" value=\"true\"/>
  10.         <!-- 是否去除自动生成的注释 true:是 : false:否 -->
  11.         <property name=\"suppressAllComments\" value=\"true\"/>
  12.     </commentGenerator>
  13.     <jdbcConnection driverClass=\"net.sourceforge.jtds.jdbc.Driver\"
  14.         connectionURL=\"jdbc:jtds:sqlserver://127.0.0.1:1433/tax\"
  15.         userId=\"tax\"
  16.         password=\"tax123\">
  17.     </jdbcConnection>
  18.     
  19.     

  20.     <javaTypeResolver >
  21.       <property name=\"forceBigDecimals\" value=\"false\" />
  22.     </javaTypeResolver>

  23.     <javaModelGenerator targetPackage=\"com.tax.model\" targetProject=\"src\">
  24.       <property name=\"enableSubPackages\" value=\"true\" />
  25.       <property name=\"trimStrings\" value=\"true\" />
  26.     </javaModelGenerator>

  27.     <sqlMapGenerator targetPackage=\"com.tax.mapper\" targetProject=\"src\">
  28.       <property name=\"enableSubPackages\" value=\"true\" />
  29.     </sqlMapGenerator>

  30.     <javaClientGenerator type=\"XMLMAPPER\" targetPackage=\"com.tax.dao\" targetProject=\"src\">
  31.       <property name=\"enableSubPackages\" value=\"true\" />
  32.     </javaClientGenerator>

  33.     <table tableName=\"charge_formula\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\" enableInsertSelective=\"false\">
  34.     </table>
  35.     <table tableName=\"charge_formula_history\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  36.     </table>
  37.     <table tableName=\"charge_plan\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  38.     </table>
  39.     <table tableName=\"charge_type\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  40.     </table>
  41.     <table tableName=\"charge_value\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  42.     </table>
  43.     <table tableName=\"charge_value_history\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  44.     </table>
  45.     <table tableName=\"company_charge\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  46.     </table>
  47.     <table tableName=\"company_order\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  48.     </table>
  49.     <table tableName=\"company_order_audit\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  50.     </table>
  51.     
  52.     <table tableName=\"device\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  53.     </table>
  54.     <table tableName=\"org_type\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  55.     </table>
  56.     <table tableName=\"project_split\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  57.     </table>
  58.     <table tableName=\"sale_charge\" enableCountByExample=\"false\" enableUpdateByExample=\"false\" enableDeleteByExample=\"false\" enableSelectByExample=\"false\" selectByExampleQueryId=\"false\">
  59.     </table>
  60.     

  61.   </context>
  62. </generatorConfiguration>
调用生成代码命令
java -jar mybatis-generator-core-1.3.2.jar -configfile config.xml -overwrite

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1701667/viewspace-1229940/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-02-11

  • 博文量
    14
  • 访问量
    46338