美文网首页
mybatis-generator

mybatis-generator

作者: hqwer | 来源:发表于2019-12-19 21:41 被阅读0次
    <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.3.2</version>
    </dependency>
    
    
    <plugin>
        <groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.2</version>
        <configuration>
            <!--配置文件的位置-->
            <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
            <verbose>true</verbose>
            <overwrite>true</overwrite>
        </configuration>
    </plugin>
    
    <?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>
    
        <!-- 当前电脑的数据库驱动程序jar包的全路径 -->
        <classPathEntry location="C:\software\java\oragin\repo\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
    
        <context id="context" targetRuntime="MyBatis3">
            <!--是否在代码中显示注释-->
            <commentGenerator>
                <property name="suppressDate" value="true" />
                <!-- 是否去除自动生成的注释 true:是 : false:否 -->
                <property name="suppressAllComments" value="true" />
            </commentGenerator>
    
            <!--数据库链接地址账号密码-->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/gp-mybatis?serverTimezone=UTC" userId="root" password="root">
            </jdbcConnection>
            <!--...-->
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
            <!--生成pojo类存放位置
              targetPackage表明要生成的文件要存放的文件夹
              targetProject表明具体路径
              比如我这里连起来就是:E:\code\hq\mybatis\src\main\java下的com.study.mybatis.pojo文件夹保存生成的pojo文件
              下面生成xml和mapper同理
            -->
            <javaModelGenerator targetPackage="com.study.mybatis.pojo" targetProject="E:\code\hq\mybatis\src\main\java">
                <property name="enableSubPackages" value="true"/>
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
            <!--生成xml映射文件存放位置-->
            <sqlMapGenerator targetPackage="mapper" targetProject="E:\code\hq\mybatis\src\main\resources">
                <property name="enableSubPackages" value="true"/>
            </sqlMapGenerator>
            <!--生成mapper类存放位置-->
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.study.mybatis.mapper" targetProject="E:\code\hq\mybatis\src\main\java">
                <property name="enableSubPackages" value="true"/>
            </javaClientGenerator>
    
            <!--生成对应表及类名-->
            <table tableName="blog" domainObjectName="Blog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
            <table tableName="author" domainObjectName="Author" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
            <table tableName="comment" domainObjectName="Comment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
    
    
        </context>
    </generatorConfiguration>
    
    image.png

    相关文章

      网友评论

          本文标题:mybatis-generator

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