本文介绍了Mybatis Generator:如何为指定的架构生成所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Mysql数据库总共有4个架构,我只想生成一个名为'booking'的指定架构.但是它总是为所有模式生成所有表.所以我需要你的帮助.下面是我的generatorConfig.xml.
Mysql database totally has 4 schemas, and I just want to generate a specified schema named 'booking'. But it always generate all tables for all schemas. So I need your help. Below is my 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>
<context id="MySqlContext" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/booking?useSSL=false"
userId="root"
password="123456">
</jdbcConnection>
<javaModelGenerator targetPackage="com.clycle.booking.entity" targetProject="C:\Users\a243903\projects\booking\webapi\src\main\java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="entity-mapper" targetProject="C:\Users\a243903\projects\booking\webapi\src\main\resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="dao" targetProject="C:\Users\a243903\projects\booking\webapi\src\main\java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table schema="booking" tableName="%">
</table>
</context>
</generatorConfiguration>
推荐答案
- 使您的表配置如下所示:
<table tableName="%"/>
- 在
<jdbcConnection>
下添加
<property name="nullCatalogMeansCurrent" value=true" />
有关更多信息,请参见此参考页: http://www.mybatis.org /generator/usage/mysql.html
See this reference page for more information: http://www.mybatis.org/generator/usage/mysql.html
这篇关于Mybatis Generator:如何为指定的架构生成所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!