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 Generator Configuration 1.0//EN"    
    <!-- Database driven-->    
         <context id="DB2Tables"  targetRuntime="MyBatis3">    
                <property name="suppressDate" value="true"/>    
                <!-- Whether to remove automatically generated comments true: Yes, false:no -->    
                <property name="suppressAllComments" value="true"/>    
            <!--Database Links URL,User name, password -->    
            <jdbcConnection driverClass="" connectionURL="jdbc:sqlserver://;databasename=redShop" userId="sa" password="kaifa">
                <property name="forceBigDecimals" value="false"/>    
            <!-- 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"/>    
            <!-- 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"/>    
            <!-- 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"/>    
            <!-- 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>  

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