• 03.generator


    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 >
      <context id="context1" >
        <commentGenerator>
           <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/jiubao" userId="root" password="" />
        <javaModelGenerator targetPackage="generator.model" targetProject="jiubao" />
        <sqlMapGenerator targetPackage="generator.map" targetProject="jiubao" />
        <javaClientGenerator targetPackage="generator.client" targetProject="jiubao" type="XMLMAPPER" />
        <table schema="jiubao" tableName="diancan" />
    
    
      </context>
    </generatorConfiguration>

    把生成的generator文件夹delete掉.重新生成一个generator文件夹.

    <?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 >
      <context id="context1" >
        <commentGenerator>
           <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/jiubao" userId="root" password="" />
        <javaModelGenerator targetPackage="generator.model" targetProject="jiubao" />
        <sqlMapGenerator targetPackage="generator.map" targetProject="jiubao" />
        <javaClientGenerator targetPackage="generator.client" targetProject="jiubao" type="XMLMAPPER" />
        <table schema="jiubao" tableName="diancan" />
        <table schema="jiubao" tableName="caipu" />
        
    
      </context>
    </generatorConfiguration>

    增加一个表,只需要到generatorConfig.xml多增加一条记录

    <table schema="jiubao" tableName="caipu" />
        

    如果菜谱表caipu增加一个字段price的话,那么

    <?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 >
      <context id="context1" >
        <commentGenerator>
           <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/jiubao" userId="root" password="" />
        <javaModelGenerator targetPackage="generator.model" targetProject="jiubao" />
        <sqlMapGenerator targetPackage="generator.map" targetProject="jiubao" />
        <javaClientGenerator targetPackage="generator.client" targetProject="jiubao" type="XMLMAPPER" />
        <table schema="jiubao" tableName="diancan" />
        <table schema="jiubao" tableName="caipu" />
        
    
      </context>
    </generatorConfiguration>
  • 相关阅读:
    第四届蓝桥杯JavaC组国(决)赛真题
    第四届蓝桥杯JavaC组国(决)赛真题
    第四届蓝桥杯JavaC组国(决)赛真题
    第四届蓝桥杯C++B组国(决)赛真题
    第四届蓝桥杯C++B组国(决)赛真题
    第四届蓝桥杯C++B组国(决)赛真题
    第四届蓝桥杯C++B组国(决)赛真题
    Qt 动画快速入门(一)
    越败越战,愈挫愈勇(人生就像心电图,一帆风顺,你就挂了!)
    CSS 编码中超级有用的工具集合
  • 原文地址:https://www.cnblogs.com/ZHONGZHENHUA/p/6924928.html
Copyright © 2020-2023  润新知