Mybatis 使用maven插件mybatis-generator自动生成entities和SQL和mapper

时间:2021-04-15 23:37:19

先安装插件

Mybatis 使用maven插件mybatis-generator自动生成entities和SQL和mapper

再写配置文件

<?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="C:/Users/Ash/.m2/repository/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar"/>
<context id="productRelease">
<property name="mergeable" value="false" />
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/springbankdb"
userId="a" password="a" />
<javaModelGenerator targetPackage="com.springbank.dao.generate.model"
targetProject="springbank-dao" />
<sqlMapGenerator targetPackage="com.springbank.dao.generate.mapper"
targetProject="springbank-dao" /> <javaClientGenerator targetPackage="com.springbank.dao.generate.mapper"
targetProject="springbank-dao" type="XMLMAPPER" />
<table tableName="owner" />
<table tableName="acctrate" />
<table tableName="acct" />
<table tableName="acctstatus" />
<table tableName="sysparam" />
<table tableName="rtxn" />
<table tableName="rate" />
<table tableName="ratetype" />
<table tableName="prod" />
<table tableName="rtxntypgl" />
<!-- <table tableName="scheduledjob" /> -->
</context>
</generatorConfiguration>