mybatise自動生成實體類和dao層代碼

1.新建generatorConfig.xml文件java

<?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:數據庫的JDBC驅動,換成你本身的驅動位置 --> 
<!-- <properties resource="util/generatorConfig.properties" />   -->
    <classPathEntry  location="C:/Users/lennon/Workspaces/MyEclipse 10/wlyteach/WebRoot/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar"/>   
    <context id="DB2Tables"  targetRuntime="MyBatis3">   
        <commentGenerator>   
            <property name="suppressDate" value="true"/>  
            <!-- 去除自動生成的註釋 -->   
            <property name="suppressAllComments" value="false"/>   
        </commentGenerator>   
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/xxx?characterEncoding=utf8" userId="root" password="root">   
        </jdbcConnection>   
        <javaTypeResolver>   
            <property name="forceBigDecimals" value="false"/>   
        </javaTypeResolver>   
        <!-- targetProject:自動生成代碼的位置 --> 
        <javaModelGenerator targetPackage="com.wanliyun.adapter.entity" targetProject="adapter">   //實體類位置
            <property name="enableSubPackages" value="true"/>   
            <property name="trimStrings" value="true"/>   
        </javaModelGenerator>   
        <sqlMapGenerator targetPackage="com.wanliyun.adapter.dao" targetProject="adapter">   
            <property name="enableSubPackages" value="true"/>   
        </sqlMapGenerator>   
        
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.wanliyun.adapter.dao" targetProject="adapter">   
            <property name="enableSubPackages" value="true"/>   
        </javaClientGenerator> 
          <!-- 生成代碼的表 -->

        <table schema="adapter" tableName="diagnose_state"></table>
       
    </context>   
</generatorConfiguration>
相關文章
相關標籤/搜索