小伙伴们注意了,全哥花了一些时间,重新整理了一个最完美的Mybatis Generator(简称MBG)配置文件详细说明,老板再也不用担心我的学习!!!
不用多说,直接上代码:
xml version="1.0" encoding="UTF-8"?>
PUBLIC "-//mybatis.org//DTD MyBatis GeneratorConfiguration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="mysqlTable" defaultModelType="hierarchical" targetRuntime="MyBatis3" >
<property name="autoDelimitKeywords" value="false">property >
<property name="javaFileEncoding" value="UTF-8">property >
<property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter">property >
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter">property >
<property name="beginningDelimiter" value="`">property >
<property name="endingDelimiter" value="`">property >
<jdbcConnection driverClass="com.mysql.jdbc.Driver"connectionURL="jdbc:mysql://120.76.77.34:3306/cms?useUnicode=true&characterEncoding=UTF-8"userId="admin" password="admin">
jdbcConnection>
<javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
<property name="forceBigDecimals" value="false"/>
javaTypeResolver>
<javaModelGenerator targetPackage="包名(如:cn.admin.sms.core.entity)" targetProject="src/main/java">
<property name="constructorBased" value="false"/>
<property name="enableSubPackages" value="true"/>
<property name="immutable" value="false"/>
<property name="rootClass" value="cn.admin.sms.core.BaseDomain"/>
<property name="trimStrings" value="true"/>
javaModelGenerator>
<sqlMapGenerator targetPackage="包名(如:cn.admin.sms.core.mapper)" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
sqlMapGenerator>
<javaClientGenerator targetPackage="包名(如:cn.admin.sms.core.mapper)" type="ANNOTATEDMAPPER" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
javaClientGenerator>
<table tableName="SmsAccurateMarketingSendContent" >
<property name="constructorBased" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="false"/>
<property name="immutable" value="false"/>
<property name="modelOnly" value="false"/>
<property name="selectAllOrderByClause" value="age desc,username asc"/>
<property name="useActualColumnNames" value="false"/>
<columnOverride column="username">
<property name="property" value="userName"/>
columnOverride>
table>
context>
generatorConfiguration>
如果不想配置在项目中的,可以单独进行配置,只需要运行generateSql.bat文件即可生成代码文件。如下图所示:
需要下载的请点击这个链接,自行下载,修改里面的相关参数便可以使用:https://download.csdn.net/download/zsq520520/10934656
generatorConfig_sql.xml完整配置代码文件如下:
好了,就到这里了,此文档可以作为一个工具文档进行查看。