Mybatis generatorConfiguration自動生成工具的使用
阿新 • • 發佈:2019-02-19
generatorConfig.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> <classPathEntry location="C:\DEV\mysql-connector-java-5.1.27.jar" /> <!-- 一個數據庫一個context --> <context id="context1"> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/dior?useUnicode=true&characterEncoding=UTF-8" userId="root" password="12345" /> <!-- 生成實體類的包名和位置 注意targetProject的值為實體類放在工程中具體位置的相對路徑,--> <javaModelGenerator targetPackage="com.business.entity"targetProject="dior" /> <!-- 生成的SQLMapper對映檔案包名和位置 --> <sqlMapGenerator targetPackage="com.datamappers"targetProject="dior" /> <!-- 生成DAO的包名和位置,這裡配置將生成的dao類放在com.business.mapper這個包下 --> <javaClientGeneratortargetPackage="com.business.mapper"targetProject="dior" type="XMLMAPPER" /> <!--配置要對映的資料庫和表名稱--> <table schema="dior" tableName="answer_info"></table> <table schema="dior" tableName="user_white"></table> </context> </generatorConfiguration>