?
?
?
整合了MySQL和Oracle配置文件生成方法
這個是整個文件夾的下載地址:http://www.codepeople.cn/download
主要給大家介紹一下generatorConfig.xml文件的配置,以及生成后的文件。
generatorConfig.xml
?
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfigurationPUBLIC "-//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-8.0.11.jar"/><context id="DB2Tables" targetRuntime="MyBatis3"><commentGenerator><property name="suppressDate" value="true"/><property name="suppressAllComments" value="true"/></commentGenerator><!--數據庫鏈接地址賬號密碼,主要Mysql版本,高版本的Mysql要加上時區--><jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/seezoon-framework?serverTimezone=GMT%2B8" userId="root" password="root"></jdbcConnection><javaTypeResolver><property name="forceBigDecimals" value="false"/></javaTypeResolver><!--生成Model類存放位置--><javaModelGenerator targetPackage="lcw.model" targetProject="src"><property name="enableSubPackages" value="true"/><property name="trimStrings" value="true"/></javaModelGenerator><!--生成映射文件存放位置--><sqlMapGenerator targetPackage="lcw.mapping" targetProject="src"><property name="enableSubPackages" value="true"/></sqlMapGenerator><!--生成Dao類存放位置--><javaClientGenerator type="XMLMAPPER" targetPackage="lcw.dao" targetProject="src"><property name="enableSubPackages" value="true"/></javaClientGenerator><!--生成對應表及類名enableCountByExample設置為false的意思就是xml中不生成這個方法和接口--><table tableName="sys_dept" domainObjectName="SysDept" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table><table tableName="sys_user" domainObjectName="SysUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table></context> </generatorConfiguration>
然后在cmd命令行下進入到Mybatis-Generator所在的目錄,然后執行命令:
java -jar mybatis-generator-core-1.3.7.jar -configfile generatorConfig.xml -overwrite
然后生成文件在src目錄下,可自行查看。