通用mapper根据多表生成代码
来源:3-11 创建项目-1

Daniyar
2019-07-02
老师,您好!我按您说的配了两个table,但是下面的那个没起作用了
写回答
1回答
-
大目
2019-07-02
您好,刚刚测试了一下,确实是可以的。我的xml:
<!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="generator/config.properties"/> <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat"> <property name="beginningDelimiter" value="`"/> <property name="endingDelimiter" value="`"/> <plugin type="tk.mybatis.mapper.generator.MapperPlugin"> <property name="mappers" value="tk.mybatis.mapper.common.Mapper"/> <property name="caseSensitive" value="true"/> <property name="lombok" value="Getter,Setter,ToString"/> </plugin> <jdbcConnection driverClass="${jdbc.driverClass}" connectionURL="${jdbc.url}" userId="${jdbc.user}" password="${jdbc.password}"> </jdbcConnection> <!--实体--> <javaModelGenerator targetPackage="com.itmuch.usercenter.domain.entity.${moduleName}" targetProject="src/main/java"/> <!--mapper.xml--> <sqlMapGenerator targetPackage="com.itmuch.usercenter.dao.${moduleName}" targetProject="src/main/resources"/> <!--mapper接口--> <javaClientGenerator targetPackage="com.itmuch.usercenter.dao.${moduleName}" targetProject="src/main/java" type="XMLMAPPER"/> <!--为哪张表生成代码--> <table tableName="user"> <generatedKey column="id" sqlStatement="JDBC"/> </table> <table tableName="bonus_event_log"> <generatedKey column="id" sqlStatement="JDBC"/> </table> </context> </generatorConfiguration>
生成的日志:
.... [INFO] Connecting to the Database [INFO] Introspecting table user [INFO] Introspecting table bonus_event_log [INFO] Generating Record class for table user [INFO] Generating Mapper Interface for table user [INFO] Generating SQL Map for table user [INFO] Generating Record class for table bonus_event_log [INFO] Generating Mapper Interface for table bonus_event_log [INFO] Generating SQL Map for table bonus_event_log [INFO] Saving file UserMapper.xml [INFO] Saving file BonusEventLogMapper.xml [INFO] Saving file User.java [INFO] Saving file UserMapper.java [INFO] Saving file BonusEventLog.java [INFO] Saving file BonusEventLogMapper.java [WARNING] Existing file /Users/itmuch.com/develop/imooc/user-center/src/main/java/com/itmuch/usercenter/dao/user/UserMapper.java was overwritten [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8.124 s [INFO] Finished at: 2019-07-02T18:25:56+08:00 [INFO] ------------------------------------------------------------------------
生成的文件:
022019-07-02
相似问题