mybatis資料庫逆向工程
阿新 • • 發佈:2018-12-30
mybatis資料庫逆向工程
所需jar包及配置檔案均在我的下載中,請自行下載
generatorConfigure.xml進行修改
1、修改資料名稱以及密碼
2、填寫java檔案生成所在包名稱(com.rr.model等)
3、填寫資料庫表名以及生成類名
<?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>
<!---->
<!-- <classPathEntry location="mysql-connector-java-5.1.39-bin.jar"/> -->
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!---->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/books" userId="root" password="root">
</jdbcConnection>
<!-- falseJDBC DECIMAL NUMERIC Integer trueJDBC DECIMAL
NUMERIC java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!--Model-->
<javaModelGenerator targetPackage="com.rr.model" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!---->
<sqlMapGenerator targetPackage="com.rr.mapping" targetProject="src">
<!-- enableSubPackages:schema -->
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!--Dao-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.rr.dao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!---->
<table tableName="userinfo" domainObjectName="UserInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="books" domainObjectName="Books" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="items" domainObjectName="OrderItem" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="orders" domainObjectName="Orders" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
修改完執行java檔案即可