<?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> <!-- 配置MySQL 驱动jar包路径.用了绝对路径 --> <classPathEntry location="D:/maven/mysql-connector-java-5.1.38.jar" /> <context id="generator" targetRuntime="MyBatis3"> <!-- 为了防止生成的代码中有很多注释,比较难看,加入下面的配置控制 --> <commentGenerator> <PRoperty name="suppressAllComments" value="true" /> <property name="suppressDate" value="true" /> <property name="javaFileEncoding" value="UTF-8" /> </commentGenerator> <!-- 注释控制完毕 --> <!-- 数据库连接 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/ssm_redis" userId="root" passWord="pwd"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 数据表对应的model 层,targetProject为当前的项目名 --> <javaModelGenerator targetPackage="com.lw.entity" targetProject="ssm_redis"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- sql mapper 隐射配置文件 --> <sqlMapGenerator targetPackage="com.lw.mapper" targetProject="ssm_redis"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 在ibatis2 中是dao层,但在mybatis3中,其实就是mapper接口 --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.lw.dao" targetProject="ssm_redis"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 要对那些数据表进行生成操作,必须要有一个,domainObjectName为要生成实体类名 --> <table tableName="t_user" domainObjectName="User" enableSelectByExample="false" enableDeleteByExample="false" enableCountByExample="false" enableUpdateByExample="false"> <generatedKey column="id" sqlStatement="JDBC" identity="true" /> </table> </context></generatorConfiguration>这里要注意配置文件中的targetPackage要先在项目中创建,才能生成具体的Class文件。3. 配置文件创建完成后,将Mysql的驱动文件下载到配置文件中classPathEntry标签下location得地址中。此时所有的工具便完成配置。具体下载地址http://pan.baidu.com/s/1qYS5oSk4. 此时右击generator.xml配置文件,选择Generate Mybatis Artifacts,此时便可自动生成所需的Class文件。下面给出中文版官方文档供大家参考:http://mbg.cndocs.tk/
新闻热点
疑难解答