1. 程式人生 > >mybatis 代碼生成器配置

mybatis 代碼生成器配置

mapper sea tab ext mybatis3 host localhost count user

eclipse安裝插件,new,新建一個Mybatis Generator Configuration File

文件內容:

<?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="
F:/NJmrk/mysql-connector-java-5.1.41.jar"/> <context id="mysql_table" 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:3306/demo" userId="root" password="123456"> </jdbcConnection> <javaTypeResolver> <property name="
forceBigDecimals" value="false" /> </javaTypeResolver> <javaModelGenerator targetPackage="com.xi.entity" targetProject="zhibing_mybatis/src/main/java"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成映射文件的包名和位置 --> <sqlMapGenerator targetPackage="com.xi.mapping" targetProject="zhibing_mybatis/src/main/java"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生成DAO的包名和位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.xi.dao" targetProject="zhibing_mybatis/src/main/java"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 要生成的實體和對應的來源表 --> <table tableName="mdept" domainObjectName="Dept" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"> <property name="useActualColumnNames" value="true" /> </table> <!-- <table schema="???" tableName="???"> <columnOverride column="???" property="???" /> </table> --> </context> </generatorConfiguration>

配置文件中,包名,開始的時候是:generator.dao,generator.entity,generator.mapping----------無法完成自動生成代碼,後改為文件中名稱後,可正常生成代碼,

具體原因不詳。

mybatis 代碼生成器配置