• Idea集成mybatis-generator


    步骤1:添加idea插件

    <build>
    <plugins>
    <!-- mybatis generator 自动生成代码插件 -->
    <plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>1.3.7</version>
    <configuration>
    <configurationFile>src/main/resources/generator/generatorConfig.xml</configurationFile>
    <overwrite>true</overwrite>
    <verbose>true</verbose>
    </configuration>
    <dependencies>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.37</version>
    </dependency>
    </dependencies>
    </plugin>
    </plugins>
    </build>

    步骤2:添加 server/src/main/resources/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="Mysql" targetRuntime="MyBatis3" defaultModelType="flat">

    <!-- <property name="autoDelimitKeywords" value="true"/>-->
    <property name="beginningDelimiter" value="`"/>
    <property name="endingDelimiter" value="`"/>

    <!--覆盖生成XML文件-->
    <!--<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />-->
    <!-- 生成的实体类添加toString()方法 -->
    <plugin type="org.mybatis.generator.plugins.ToStringPlugin" />

    <!-- 不生成注释 -->
    <commentGenerator>
    <property name="suppressAllComments" value="true"/>
    </commentGenerator>

    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
    connectionURL="jdbc:mysql://localhost:3306/courseimooc"
    userId="courseimooc"
    password="courseimooc">
    </jdbcConnection>

    <!-- domain类的位置 -->
    <javaModelGenerator targetProject="srcmainjava"
    targetPackage="com.course.server.domain"/>

    <!-- mapper xml的位置 -->
    <sqlMapGenerator targetProject="srcmain esources"
    targetPackage="mapper"/>

    <!-- mapper类的位置 -->
    <javaClientGenerator targetProject="srcmainjava"
    targetPackage="com.course.server.mapper"
    type="XMLMAPPER" />

    <table tableName="test" domainObjectName="Test"/>
    </context>
    </generatorConfiguration>

    步骤3:添加maven命令 

    mybatis-generator:generate -e 

  • 相关阅读:
    P1478 陶陶摘苹果(升级版)
    洛谷 P1008 三连击
    1412:二进制分类
    1411:区间内的真素数
    判断素数
    关于小数
    一本通题库1159斐波那契数列
    一本通题库1161转进制
    一本通题1051
    基础算法——数据排序——冒泡
  • 原文地址:https://www.cnblogs.com/cct1314520/p/13388618.html
Copyright © 2020-2023  润新知