Automation 是否可以使用MyBatis生成器一次为所有表生成工件?
我正在从命令行使用MyBatis Generator 1.3.1。我在文档中读到,我需要为对象生成指定至少一个表,但我希望可以使用一些通配符,并为一次生成的所有表使用映射器?我们不想使用Hibernate,因为MyBatis似乎可以更好地处理数据库中的自定义类型。Automation 是否可以使用MyBatis生成器一次为所有表生成工件?,automation,mybatis,Automation,Mybatis,我正在从命令行使用MyBatis Generator 1.3.1。我在文档中读到,我需要为对象生成指定至少一个表,但我希望可以使用一些通配符,并为一次生成的所有表使用映射器?我们不想使用Hibernate,因为MyBatis似乎可以更好地处理数据库中的自定义类型。 谢谢你的帮助 您可以使用SQL通配符,即: <table tableName="%"> <property name="useActualColumnNames" value="true"/> <
谢谢你的帮助 您可以使用SQL通配符,即:
<table tableName="%">
<property name="useActualColumnNames" value="true"/>
</table>
您可以参考:
如果使用MySQL,关键点是:谢谢你,@bhutten!您知道configuration.xml文件的一节中有一个类似的技巧,它会同时生成指向所有生成映射器的路径吗?
<generatorConfiguration>
<properties resource="mybatis-generator/generator.properties"></properties>
<classPathEntry location="${driverLocation}"/>
<context id="default" targetRuntime="MyBatis3">
<property name="javaFileEncoding" value="UTF-8"/>
<commentGenerator type="org.zhang.generator.MyCommentGenerator">
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<jdbcConnection
driverClass="${driverClassName}"
connectionURL="${url}"
userId="${username}"
password="${password}">
<property name="nullCatalogMeansCurrent" value="true" />
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="true"/>
</javaTypeResolver>
<javaModelGenerator targetPackage="com.entity" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="daoMappers" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator targetPackage="com.dao" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table schema="dbName" tableName="%"
enableSelectByPrimaryKey="true"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
enableDeleteByPrimaryKey="false"
enableUpdateByPrimaryKey="false"
enableInsert="false">
<property name="useActualColumnNames" value="true"></property>
</table>
</generatorConfiguration>