根据数据库表名,自动生成基础CURD语句

<?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">
<!--
拷入IDEAXML文件,Line13,Line21,Line25,Line30,Line35
以及后续数据库对应表名需要修改


-->
<generatorConfiguration>
    <!--数据库驱动包路径 -->
    <classPathEntry location="D:\mine\maven\repo\mysql\mysql-connector-java\8.0.23\mysql-connector-java-8.0.23.jar"/>
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <!--关闭注释 -->
        <commentGenerator>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!--数据库连接信息 -->
<!--                <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="${spring.datasource.url}" userId="${spring.datasource.username}" password="${spring.datasource.password}">-->
        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/big_strong?serverTimezone=UTC"  userId="root" password="root">

        </jdbcConnection>
        <!--生成的model 包路径 -->
        <javaModelGenerator targetPackage="com.example.demo.pojo" targetProject="src/main/java">
            <property name="enableSubPackages" value="ture"/>
            <property name="trimStrings" value="false"/>
        </javaModelGenerator>
        <!--生成xml mapper文件 路径 -->
        <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
            <property name="enableSubPackages" value="ture"/>
        </sqlMapGenerator>

        <!-- 生成的Dao接口 的包路径 -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.example.demo.mapper" targetProject="src/main/java">
            <property name="enableSubPackages" value="ture"/>
        </javaClientGenerator>
        <!--对应数据库表名 -->
        <table tableName="role" domainObjectName="Role" enableCountByExample="false"
               enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
            <property name="useActualColumnNames" value="true"/>
        </table>
        <table tableName="permission" domainObjectName="Permission" enableCountByExample="false"
               enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
            <property name="useActualColumnNames" value="true"/>
        </table>
        <table tableName="user_role" domainObjectName="UserRole" enableCountByExample="false"
               enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
            <property name="useActualColumnNames" value="true"/>
        </table>
        <table tableName="role_permission" domainObjectName="RolePermission" enableCountByExample="false"
               enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false">
            <property name="useActualColumnNames" value="true"/>
        </table>
    </context>
</generatorConfiguration>

对应的POM

  <!-- Mybatis generator代码生成插件 配置 -->
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.1</version>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.15</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
                    <overwrite>true</overwrite>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值