zoukankan      html  css  js  c++  java
  • mybatis基础学习4-插件生成器(根据数据库的表生成文件)

    1:安装(根据数据库的表生成文件)

    2:在所建项目单击右键输入mybatis如下图

    *建项目文件时不用建包和类,插件可以根据数据自动生成,在配置文件(generatorConfig.xml)里写即可生成

     3:src文件夹为空不用写东西,之后在项目生成generatorConfig.xml配置文件

    详细说明

     

    自己建的表(这个必须,插件会根据建表的字段生成文件属性)

    单击右键run运行

    即可

    -------------------------------------------------------------------------------------------------------------------------

     配置文件填写示例如下

    <?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>
    <!-- 指定mysql的驱动包的路径 千万别放中文路径下 -->
    <classPathEntry location="C:UsersAdministratorDesktopmysql-connector-java-5.1.7-bin.jar" />
    <!-- 配置数据源和生成的代码所存放的位置 -->
    <context id="context1">
    
    <commentGenerator>
    <!-- 去除自动生成的注释 -->
    <property name="suppressAllComments" value="true" />
    </commentGenerator>
    
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
    connectionURL="jdbc:mysql://127.0.0.1:3306/mybatis" userId="root"
    password="" />
    <!-- 所生成的实体类的位置默认资源包src -->
    <javaModelGenerator targetPackage="com.rjxy.model"
    targetProject="test01" />
    <!-- 所生成的sqlMap的影射文件的位置,默认资源包src -->
    <sqlMapGenerator targetPackage="com.rjxy.sql.mapper"
    targetProject="test01" />
    
    <!-- 为哪些表生成代码 tableName:表名 schema:不用填写,其余属性是禁用例子查询的生成 -->
    <table schema="" tableName="student" enableCountByExample="false"
    enableUpdateByExample="false" enableDeleteByExample="false"
    enableSelectByExample="false" selectByExampleQueryId="false">
    </table>
    
    </context>
    </generatorConfiguration>
  • 相关阅读:
    php ReflectionObject类
    is_callable
    Zend Framework: Accessing Request, Response & Router Object from anywhere
    (转)zend异常处理
    call_user_func
    zend framework基础教程6—视图
    php func_get_arg
    zend framework基础教程3—创建index.php
    【算法02】3种方法求解斐波那契数列
    【算法01】寻找丑数
  • 原文地址:https://www.cnblogs.com/kaiwen/p/6498535.html
Copyright © 2011-2022 走看看