Mybatis automatically generators Config. XML

Keywords: Mybatis Database xml Eclipse

Install plug-ins first

Eclipse: help - > Eclipse Marketplace... - > find input box, enter MyBatis Generator - > search completed, and click Install in the bottom right corner of the latest version (if it is Installed, you don't need to install it)

idea to be added...

Create an xml file under src/main/resources / and copy the following code into it. Then modify the database connection address, package name, generated address, database and entity class name

<?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>    
    <!-- Database driven-->    
         <context id="DB2Tables"  targetRuntime="MyBatis3">    
            <commentGenerator>    
                <property name="suppressDate" value="true"/>    
                <!-- Whether to remove automatically generated comments true: Yes, false:no -->    
                <property name="suppressAllComments" value="true"/>    
            </commentGenerator>    
            <!--Database Links URL,User name, password -->    
            <jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver" connectionURL="jdbc:sqlserver://61.163.37.23:1433;databasename=redShop" userId="sa" password="kaifa">
		</jdbcConnection>
            <javaTypeResolver>    
                <property name="forceBigDecimals" value="false"/>    
            </javaTypeResolver>    
            <!-- Package name and location of the generated model-->    
            <javaModelGenerator targetPackage="com.ruoyi.redshop.entity" targetProject="redshop-admin/src/main/java">    
                <property name="enableSubPackages" value="true"/>    
                <property name="trimStrings" value="true"/>    
            </javaModelGenerator>    
            <!-- Generate the package name and location of the mapping file-->    
            <sqlMapGenerator targetPackage="mybatis.mapper" targetProject="redshop-admin/src/main/resources">    
                <property name="enableSubPackages" value="true"/>    
            </sqlMapGenerator>    
            <!-- generate DAO The package name and location of-->    
            <javaClientGenerator type="XMLMAPPER" targetPackage="com.ruoyi.redshop.mapper" targetProject="redshop-admin/src/main/java">    
                <property name="enableSubPackages" value="true"/>    
            </javaClientGenerator>    
            <!-- Tables to be generated tableName Is the table name or view name in the database domainObjectName Is the entity class name-->    
            <table tableName="UVCount" domainObjectName="UVCount" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
        </context>    
    </generatorConfiguration> 

After the modification is completed, right-click GeneorConfig. XML - > Run As - > Run Mybatis Generator to see if the console prints BUILD SUCCESSFUL, and then go to the corresponding directory to see if it exists.

Posted by eco on Mon, 30 Sep 2019 15:32:47 -0700