美文网首页
mybatis-generator

mybatis-generator

作者: _小生不才_ | 来源:发表于2019-05-09 15:00 被阅读0次

    1.pom.xml添加依赖

    <dependency>

    <groupId>org.mybatis.generator</groupId>

    <artifactId>mybatis-generator-core</artifactId>

    <version>1.3.6</version>

    </dependency>

    2.pom.xml添加插件

    <plugin>

    <groupId>org.mybatis.generator</groupId>

    <artifactId>mybatis-generator-maven-plugin</artifactId>

    <version>1.3.6</version>

    <configuration>

    <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>

    <verbose>true</verbose>

    <overwrite>true</overwrite>

    </configuration>

    <executions><execution>

    <id>Generate MyBatis Artifacts</id>

    <goals><goal>generate</goal></goals>

    </execution></executions>

    </plugin>

    3.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">

    <classPathEntry  location="C:\Users\SMZ\.m2\repository\mysql\mysql-connector-java\5.1.42\mysql-connector-java-5.1.42.jar"/>

        <context id="DB2Tables"  targetRuntime="MyBatis3">

                <property name="suppressDate" value="true"/>

                <property name="suppressAllComments" value="true"/>

    <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.0.150:3306/sx_shop?useSSL=true" userId="root" password="123456">

                 <property name="forceBigDecimals" value="false"/>

                  <javaModelGenerator targetPackage="com.spring.model" targetProject="src/main/java">

                    <property name="enableSubPackages" value="true"/>

                    <property name="trimStrings" value="true"/>

                     <sqlMapGenerator targetPackage="com.spring.mapper" targetProject="src/main/java">

                    <property name="enableSubPackages" value="true"/>

                     <javaClientGenerator type="XMLMAPPER" targetPackage="com.spring.dao" targetProject="src/main/java">

                   <property name="enableSubPackages" value="true"/>

         <table tableName="hm_user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">

    </generatorConfiguration>

    4.运行

    相关文章

      网友评论

          本文标题:mybatis-generator

          本文链接:https://www.haomeiwen.com/subject/eauwoqtx.html