美文网首页
MybatisGenerator

MybatisGenerator

作者: 尼尔君 | 来源:发表于2018-12-19 11:54 被阅读0次

    插件

    
     <plugin>
                    <groupId>org.mybatis.generator</groupId>
                    <artifactId>mybatis-generator-maven-plugin</artifactId>
                    <configuration>
                        <configurationFile>src/main/resources/generator/generatorConfig.xml</configurationFile>
                        <verbose>true</verbose>
                        <overwrite>true</overwrite>
                    </configuration>
    
                    <executions>
                        <execution>
                            <id>Generate MyBatis Artifacts</id>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                    <dependency>
                        <groupId>org.mybatis.generator</groupId>
                        <artifactId>mybatis-generator-core</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                   <dependency>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                            <version>8.0.13</version>
                        </dependency>
    
                    </dependencies>
                </plugin>
    
    
    

    Configuration .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 >
       
    
        <!-- 此处指定生成针对MyBatis3的相关类,xml -->
        <context id="context1" targetRuntime="MyBatis3">
    
            <!-- jdbc连接信息 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/order?characterEncoding=utf8" userId="root" password="root" />
    
            <!-- 生成vo对象  -->
            <javaModelGenerator targetPackage="com.boolib.shiro.springboot1.model" targetProject="src/main/java" >
                <property name="enableSubPackages" value="true" />
                <property name="trimStrings" value="true" />
            </javaModelGenerator>
    
            <!--生成映射文件存放位置-->
            <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
                <property name="enableSubPackages" value="true" />
            </sqlMapGenerator>
    
            <!--生成Model类存放位置-->
            <javaClientGenerator
                    targetPackage="com.boolib.shiro.springboot1.dao"
                    targetProject="src/main/java" type="XMLMAPPER" />
    
            <table tableName="users"
                   domainObjectName="User"
                   enableCountByExample="false"
                   enableUpdateByExample="false"
                   enableDeleteByExample="false"
                   enableSelectByExample="false"
                   selectByExampleQueryId="false">
            </table>
    
    
    
        </context>
    </generatorConfiguration>
    
    
    
    

    相关文章

      网友评论

          本文标题:MybatisGenerator

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