Generate自动代码生成器---MyBatis

Generate可以自动生成mapper.xml文件,和mapper接口以及实体类,并自动生成简单的sql语句,可以直接使用。下面直接上代码:
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>
    <!-- 需要填写mysql-connector-java-5.1.7-bin.jar在电脑中的地址 -->
    <classPathEntry location="mysql-connector-java-5.1.47.jar" />
 
    <context id="context1">
        <!-- 注释 -->
        <commentGenerator>
            <property name="suppressAllComments" value="true" /><!-- 是否取消注释 -->
            <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳 -->
        </commentGenerator>
        <!-- 填写数据库信息 -->
        <jdbcConnection connectionURL="jdbc:mysql://localhost:3306/appinfodb"
            driverClass="com.mysql.jdbc.Driver" password="root" userId="root" />
 
 
        <!-- 类型转换 -->
        <javaTypeResolver>
            <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
		<!--生成实体类-->
        <javaModelGenerator targetPackage="com.xxl.entity"
            targetProject=".">
            <property name="enableSubPackages" value="true" />
			<!--从数据库返回的值被清理空格-->
            <property name="trimStrings" value="true" />
        </javaModelGenerator>
		<!--对应的mapper.xml-->
        <sqlMapGenerator targetPackage="mapper"
            targetProject=".">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>
		<!--对应的mapper接口类配置文件-->
        <javaClientGenerator targetPackage="com.xxl.mapper"
        targetProject="." type="XMLMAPPER" >
        <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
 
        <table schema="" tableName="ad_promotion"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
			<table schema="" tableName="app_category"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
			<table schema="" tableName="app_info"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
			<table schema="" tableName="app_version"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
			<table schema="" tableName="backend_user"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
			<table schema="" tableName="data_dictionary"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
			<table schema="" tableName="dev_user"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false" />
    </context>
</generatorConfiguration>

run.bat

java -jar mybatis-generator-core-1.3.5.jar -configfile generatorConfig.xml

下面附上所有的jar包以及文件
在这里插入图片描述
会自动生成下面两个目录的文件
在这里插入图片描述

关注公众号
在这里插入图片描述

每周会更新干货知识

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值