1. <!-- mybatis generator 自动生成代码插件 -->
    2. <plugin>
    3. <groupId>org.mybatis.generator</groupId>
    4. <artifactId>mybatis-generator-maven-plugin</artifactId>
    5. <version>1.3.2</version>
    6. <configuration>
    7. <configurationFile>D:/genCode/generatorConfig.xml</configurationFile>
    8. <overwrite>true</overwrite>
    9. <verbose>true</verbose>
    10. </configuration>
    11. </plugin>
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!DOCTYPE generatorConfiguration
    3. PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
    4. "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
    5. <generatorConfiguration>
    6. <!-- 配置文件路径 -->
    7. <!-- <properties resource="generator.properties" /> -->
    8. <!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
    9. <classPathEntry location="D:/Local_Repository/ivy-cache/oracle/ojdbc/jars/ojdbc-16.jar"/>
    10. <context id="DB2Tables" targetRuntime="MyBatis3">
    11. <commentGenerator>
    12. <property name="suppressDate" value="true"/>
    13. <!-- 是否去除自动生成的注释 true:是 : false:否 -->
    14. <property name="suppressAllComments" value="true"/>
    15. </commentGenerator>
    16. <!--数据库链接URL,用户名、密码 -->
    17. <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@xxx.xxx.xx.xxx:1530:db" userId="xxx" password="xxx">
    18. </jdbcConnection>
    19. <javaTypeResolver>
    20. <property name="forceBigDecimals" value="false"/>
    21. </javaTypeResolver>
    22. <!-- 生成模型的包名和位置-->
    23. <javaModelGenerator targetPackage="entity" targetProject="D:\genCode">
    24. <property name="enableSubPackages" value="true"/>
    25. <property name="trimStrings" value="true"/>
    26. </javaModelGenerator>
    27. <!-- 生成映射文件的包名和位置-->
    28. <sqlMapGenerator targetPackage="mapper" targetProject="D:\genCode">
    29. <property name="enableSubPackages" value="true"/>
    30. </sqlMapGenerator>
    31. <!-- 生成DAO的包名和位置-->
    32. <javaClientGenerator type="XMLMAPPER" targetPackage="mapper" targetProject="D:\genCode">
    33. <property name="enableSubPackages" value="true"/>
    34. </javaClientGenerator>
    35. <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
    36. <table tableName="t_member_info" domainObjectName="MemberInfo" enableCountByExample="true"
    37. enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
    38. </table>
    39. <table tableName="t_account" domainObjectName="Account" enableCountByExample="true"
    40. enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
    41. </table>
    42. </context>
    43. </generatorConfiguration>
    1. # maven generator
    2. mvn mybatis-generator:generate -e