mybatis-generator使用之generatorConfig.xml配置文件

二、generatorConfig.xml配置文件

在项目中放入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 ="mysql-connector-java-5.1.25-bin.jar" />
< context id ="context1" targetRuntime ="MyBatis3Simple" >
< commentGenerator >

< property name ="suppressAllComments" value ="false" />
< property name ="suppressDate" value ="true" />
 
commentGenerator >

     
< jdbcConnection driverClass ="com.mysql.jdbc.Driver" connectionURL ="jdbc:mysql://127.0.0.1:3306/你的数据库名" userId ="root" password ="root" />
 
< javaTypeResolver >

< property name ="forceBigDecimals" value ="false" />
  javaTypeResolver >

         
< javaModelGenerator targetPackage ="com.dayhr.web.module.hr.sm.salary.model" targetProject ="dayhr_app\src" >

< property name ="enableSubPackages" value ="false" />

< property name ="trimStrings" value ="true" />
javaModelGenerator >


< sqlMapGenerator targetPackage ="com.dayhr.web.module.hr.sm.salary.mapper" targetProject ="dayhr_app\src" >

< property name ="enableSubPackages" value ="false" />
sqlMapGenerator >


< javaClientGenerator targetPackage ="com.dayhr.web.module.hr.sm.salary.mapper" targetProject ="dayhr_app\src" type ="XMLMAPPER" >

< property name ="enableSubPackages" value ="false" />
javaClientGenerator >


 
40         <table tableName="CTAS_FEE_BASE" domainObjectName="FeeBase"
41                enableCountByExample="false" enableUpdateByExample="false"
42                enableDeleteByExample="false" enableSelectByExample="false"
43                selectByExampleQueryId="false">
44         
45         table>
context >
generatorConfiguration >
其中:

classPathEntry     location:驱动地址,放入数据库对应的jdbc驱动jar路径(绝对路径)

jdbcConnection   driverClass:驱动类(如oracle.jdbc.driver.OracleDriver),connectionURL:jdbc链接串(如jdbc:oracle:thin:@192.168.1.188:1521:xxx"), userId:数据用户名,password:数据库密码

javaModelGenerator  targetPackage:生成的pojo放入的包, targetProject:生成的pojo放入的项目(对应工作空间的项目)

sqlMapGenerator   targetPackage=生成的sql对应的包  targetProject:生成的sql接口对应的项目

javaClientGenerator  targetPackage:生成的dao接口对应的包  targetProject:生成的dao接口对应的项目  type:映射文件类型,一般为XMLMAPPER

table:tableName:需要生成的表名,domainObjectName:生成的pojo名,为空则对应数据库表名



你可能感兴趣的:(MyBatis)