mybatis generator 是一个代码生成工具,默认生成model,dao和 sql.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>
<properties resource="priv/serviceControllerGenConfig.properties"/>
<!--数据库驱动-->
<classPathEntry
location="C:\development\mavenRepository\mysql\mysql-connector-java\5.1.44\mysql-connector-java-5.1.44.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3" >
<property name="autoDelimitKeyWords" value="true"/>
<!--<plugin type="priv.hu.MyPlugin"></plugin>-->
<plugin type="plugin.ServiceControllerPlugin"/>
<plugin type="plugin.LomBokAnnotationPlugin"/>
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
<!--生成的代码中的注释生成器-->
<commentGenerator>
<!--<property name="suppressDate" value="true"/>-->
<!--不生成注释-->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接地址账号密码-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost/mall"
userId="root"
password="hu961212">
</jdbcConnection>
<!--生成Model类存放位置-->
<javaModelGenerator targetPackage="${model_package}" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!--生成映射文件存放位置-->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<!--<property name="enableSubPackages" value="true"/>-->
</sqlMapGenerator>
<!--生成java接口或类-->
<javaClientGenerator type="XMLMAPPER" targetPackage="priv.hu.dao"
targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--生成对应表及类名-->
<table tableName="goods" domainObjectName="Goods" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" mapperName="GoodsDao">
</table>
<table tableName="goods_cat" domainObjectName="GoodsCat" enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" mapperName="GoodsCatDao"></table>
</context>
</generatorConfiguration>
网友评论