逆向工程运行类:GenneratorSqlMap
import java.io.File; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List;
import org.mybatis.generator.api.MyBatisGenerator; import org.mybatis.generator.config.Configuration; import org.mybatis.generator.config.xml.ConfigurationParser; import org.mybatis.generator.exception.InvalidConfigurationException; import org.mybatis.generator.exception.XMLParserException; import org.mybatis.generator.internal.DefaultShellCallback;
public class GenneratorSqlMap {
public void generator() throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException{ //warnings为用于放置生成过程中警告信息的集合对象 List<String> warnings = new ArrayList<String>();
//指定DefaultShellCallback是否覆盖重名文件 boolean overwrite = true;
//加载配置文件 File configFile = new File("generatorConfig.xml");
//配置解析类 ConfigurationParser cp = new ConfigurationParser(warnings);
//配置解析类解析配置文件并生成Configuration配置对象 Configuration config = cp.parseConfiguration(configFile);
//DefaultShellCallback负责如何处理重复文件 DefaultShellCallback callback = new DefaultShellCallback(overwrite);
//逆向工程对象 MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
//执行逆向文件生成操作 myBatisGenerator.generate(null); }
public static void main(String[] args) throws Exception{
GenneratorSqlMap genneratorSqlMap = new GenneratorSqlMap();
genneratorSqlMap.generator();
} }
|
逆向工程日志文件:log4j.properties
log4j.rootLogger=DEBUG, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n |
逆向工程需要的JAR:
逆向工程配置文件: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="testTables" targetRuntime="Mybatis3"> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="false"/> </commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 --> <!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/huancheng" userId="root" password="*******"> </jdbcConnection> -->
<!-- Oracle 数据库连接 --> <jdbcConnection connectionURL="jdbc:oracle:thin:@//192.168.3.196:1521/project" driverClass="oracle.jdbc.driver.OracleDriver" password="admin" userId="tom"> <!-- 针对oracle数据库 --> <property name="remarksReporting" value="true"></property> </jdbcConnection>
<!--默认false,把JDBC DECIMAL和 NUMERIC类型解析为Integer, 为 true时把JDBC DECIMAL和NUMERIC类型解析为java.math.BigDecimal--> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver>
<!-- targetProject:生成PO类的位置 --> <javaModelGenerator targetPackage="com.znsd.mall.bean" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false"/> <!-- 从数据库返回的值被清理前后的空格 --> <property name="trimStrings" value="true"/> </javaModelGenerator>
<!-- targetProject:mapper映射文件生成的位置 --> <sqlMapGenerator targetPackage="com.znsd.mall.dao.mapper" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false"/> </sqlMapGenerator>
<!-- targetPackage:mapper接口生成的位置 --> <javaClientGenerator targetPackage="com.znsd.mall.dao.mapper" type="XMLMAPPER" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false"/> </javaClientGenerator>
<!-- 指定数据库表 --> <!-- MySQL 数据库表 --> <!-- <table tableName="t_additional_comment"></table> <table tableName="t_administrator"></table> <table tableName="t_application_info"></table> <table tableName="t_comment"></table> <table tableName="t_coupon"></table> <table tableName="t_depository"></table> <table tableName="t_depository_record"></table> <table tableName="t_dictionary"></table> <table tableName="t_goods"></table> <table tableName="t_goods_record"></table> <table tableName="t_goods_types"></table> <table tableName="t_order"></table> <table tableName="t_order_detail"></table> <table tableName="t_order_logistics"></table> <table tableName="t_order_sales"></table> <table tableName="t_ralance"></table> <table tableName="t_role_info"></table> <table tableName="t_specification"></table> <table tableName="t_store"></table> <table tableName="t_supplier"></table> -->
<!-- Oracle 数据库表 --> <table tableName="t_goods_collect"></table> <!-- 指定java类型 --> <!-- 要生成哪些表(更改tableName和domainObjectName就可以) --> <!-- tableName:要生成的表名 domainObjectName:生成后的实例名 enableCountByExample:Count语句中加入where条件查询,默认为true开启 enableUpdateByExample:Update语句中加入where条件查询,默认为true开启 enableDeleteByExample:Delete语句中加入where条件查询,默认为true开启 enableSelectByExample:Select多条语句中加入where条件查询,默认为true开启 selectByExampleQueryId:Select单个对象语句中加入where条件查询,默认为true开启 <ignoreColumn column="FRED" />//忽略字段 <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" />//无论字段是什么类型,生成的类属性都是varchar。
--> <!--不生成帮助类(Exmaples) --> <!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" --> <!--已生成的表 <table schema="demo" tableName="USER" domainObjectName="User"></table> --> <table schema="" tableName="t_additional_comment" domainObjectName="AdditionalCommentBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="REPLY_Time" javaType="String" /> </table> <!-- <table schema="true" tableName="product"> <columnOverride column="price" javaType="java.lang.Double"></columnOverride> </table> --> </context> </generatorConfiguration> |
log4j 日志:log4j.properties
log4j.rootLogger=DEBUG, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n |
Maven 工程:
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.darryl.generator</groupId> <artifactId>SpringbootMybatisGenerator</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.1.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!-- 测试 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <!-- mybatis 依赖组件 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version> </dependency> <!-- mysql 依赖 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency>
<!-- Oracle --> <!-- <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>6.0</version> </dependency> --> <!-- oracle --> <dependency> <groupId>com.github.noraui</groupId> <artifactId>ojdbc8</artifactId> <version>12.2.0.1</version> </dependency>
<dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.5</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <dependencies> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.2</version> </dependency> </dependencies> </plugin> </plugins> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> <include>**/*.sql</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>
<!-- <build> <finalName>mybatis-generator-core-1.3.2</finalName> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <configuration> <appendAssemblyId>false</appendAssemblyId> <archive> <manifest> <mainClass>org.mybatis.generator.api.ShellRunner</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>assembly</goal> </goals> </execution> </executions> </plugin> </plugins> </build> --> </project> |
CustomCommentGenerator.java
package com.darryl.generator; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.mybatis.generator.api.IntrospectedColumn; import org.mybatis.generator.api.IntrospectedTable; import org.mybatis.generator.api.MyBatisGenerator; import org.mybatis.generator.api.dom.java.Field; import org.mybatis.generator.config.Configuration; import org.mybatis.generator.config.xml.ConfigurationParser; import org.mybatis.generator.internal.DefaultCommentGenerator; import org.mybatis.generator.internal.DefaultShellCallback; public class CustomCommentGenerator extends DefaultCommentGenerator { // @Override // public void addFieldComment(Field field, IntrospectedTable introspectedTable, // IntrospectedColumn introspectedColumn) { // // 添加字段注释 // field.addJavaDocLine("/**"); // if (introspectedColumn.getRemarks() != null) { // field.addJavaDocLine(" * " + introspectedColumn.getRemarks()); // } // // addJavadocTag(field, false); // field.addJavaDocLine(" */"); // } public static void main(String[] args) throws Exception { try { List<String> warnings = new ArrayList(); boolean overwrite = true; ClassLoader classloader = Thread.currentThread().getContextClassLoader(); InputStream is = classloader.getResourceAsStream("generatorConfig.xml"); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(is); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); myBatisGenerator.generate(null); System.out.println("生成成功"); } catch (Exception e) { e.printStackTrace(); } } } |
MyCommentGenerator.java
package com.darryl.generator;
import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties;
import org.mybatis.generator.api.IntrospectedColumn; import org.mybatis.generator.api.IntrospectedTable; import org.mybatis.generator.api.dom.java.Field; import org.mybatis.generator.api.dom.java.InnerClass; import org.mybatis.generator.api.dom.java.Method; import org.mybatis.generator.internal.DefaultCommentGenerator;
public class MyCommentGenerator extends DefaultCommentGenerator { private Properties properties; private Properties systemPro; private boolean suppressDate; private boolean suppressAllComments; private String currentDateStr; public MyCommentGenerator() { super(); properties = new Properties(); systemPro = System.getProperties(); suppressDate = false; suppressAllComments = false; currentDateStr = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()); } public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) { if (suppressAllComments) { return; } StringBuilder sb = new StringBuilder(); field.addJavaDocLine("/**"); sb.append(" * "); sb.append(introspectedColumn.getRemarks()); field.addJavaDocLine(sb.toString().replace("\n", " ")); field.addJavaDocLine(" */"); } public void addFieldComment(Field field, IntrospectedTable introspectedTable) { } public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) { } public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) { } public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) { } public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) { } public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) { } }
|
log4j.properties
log4j.rootLogger=DEBUG, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n |
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:起个名字 --> <!-- targetRuntime:设置生成的文件适用于那个 mybatis 版本 --> <context id="context1" targetRuntime="MyBatis3">
<!-- 指定生成的java文件的编码,没有直接生成到项目时中文可能会乱码 --> <property name="javaFileEncoding" value="UTF-8"/> <!-- 使用自定义的插件 --> <!--optional,旨在创建class时,对注释进行控制--> <commentGenerator type="com.darryl.generator.MyCommentGenerator"> <property name="suppressDate" value="true" /> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator>
<!-- oracle配置 --> <!-- <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@***:1521:orcl" userId="***" password="***"> 针对oracle数据库 <property name="remarksReporting" value="true"></property> </jdbcConnection> -->
<!-- mysql配置 5.X--> <!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.42:3306/huancheng" userId="root" password="******"> 针对mysql数据库 <property name="useInformationSchema" value="true"></property> </jdbcConnection> -->
<!--jdbc的数据库连接 8.X--> <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/huancheng?serverTimezone=UTC" userId="root" password="******"> </jdbcConnection> <!--指定生成的类型为java类型,避免数据库中number等类型字段 --> <!--默认false,把JDBC DECIMAL和 NUMERIC类型解析为Integer, 为 true时把JDBC DECIMAL和NUMERIC类型解析为java.math.BigDecimal--> <!--非必须,类型处理器,在数据库类型和java类型之间的转换控制--> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver>
<!-- targetPackage:生成的实体类所在的包 --> <!-- targetProject:生成的实体类所在的硬盘位置 --> <!--自动生成的实体的存放包路径 --> <javaModelGenerator targetPackage="com.znsd.mall.bean" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <!-- 是否允许子包 --> <property name="enableSubPackages" value="true" /> <!-- 是否清理从数据库中查询出的字符串左右两边的空白字符 --> <property name="trimStrings" value="true" />
<!-- 是否对modal添加构造函数 --> <property name="constructorBased" value="true" />
<!-- 建立modal对象是否不可改变 即生成的modal对象不会有setter方法,只有构造方法 --> <property name="immutable" value="false" /> </javaModelGenerator> <!--自动生成的*Mapper.xml文件存放路径 --> <sqlMapGenerator targetPackage="com.znsd.mall.dao.mapper" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <!-- 针对数据库的一个配置,是否把 schema 作为字包名 --> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!--自动生成的*Mapper.java存放路径 --> <javaClientGenerator targetPackage="com.znsd.mall.dao.mapper" type="XMLMAPPER" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!--不生成帮助类(Exmaples) --> <!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" --> <!--已生成的表 <table schema="demo" tableName="USER" domainObjectName="User"></table> --> <table schema="" tableName="t_additional_comment" domainObjectName="AdditionalCommentBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="REPLY_Time" javaType="String" /> </table>
<table schema="" tableName="t_administrator" domainObjectName="AdministratorBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_application_info" domainObjectName="ApplicationInfoBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_comment" domainObjectName="CommentBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="comment_reply" javaType="String" /> </table> <table schema="" tableName="t_coupon" domainObjectName="CouponBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="start_time" javaType="String" /> <columnOverride column="end_time" javaType="String" /> </table>
<table schema="" tableName="t_depository" domainObjectName="DepositoryBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_depository_record" domainObjectName="DepositoryRecordBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="time" javaType="String" /> </table>
<table schema="" tableName="t_dictionary" domainObjectName="DictionaryBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_goods" domainObjectName="GoodsBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_goods_record" domainObjectName="GoodsRecordBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="time" javaType="String" /> </table>
<table schema="" tableName="t_goods_types" domainObjectName="GoodsTypesBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_order" domainObjectName="OrderBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="delivery_time" javaType="String" /> <columnOverride column="finish_time" javaType="String" /> <columnOverride column="closing_time" javaType="String" /> </table>
<table schema="" tableName="t_order_detail" domainObjectName="OrderDetailBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_order_logistics" domainObjectName="OrderLogisticsBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="shipments_time" javaType="String" /> <columnOverride column="delivery_time" javaType="String" /> <columnOverride column="sign_off_time" javaType="String" /> </table>
<table schema="" tableName="t_order_sales" domainObjectName="OrderSalesBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="refund_time" javaType="String" /> <columnOverride column="processing_time" javaType="String" /> </table>
<table schema="" tableName="t_ralance" domainObjectName="RalanceBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_role_info" domainObjectName="RoleInfoBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_specification" domainObjectName="SpecificationBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_store" domainObjectName="StoreBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="open_time" javaType="String" /> <columnOverride column="close_time" javaType="String" /> </table>
<table schema="" tableName="t_supplier" domainObjectName="SupplierBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table> </context> </generatorConfiguration> |
Oracle 中 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:起个名字 --> <!-- targetRuntime:设置生成的文件适用于那个 mybatis 版本 --> <context id="context1" targetRuntime="MyBatis3">
<!-- 指定生成的java文件的编码,没有直接生成到项目时中文可能会乱码 --> <property name="javaFileEncoding" value="UTF-8"/> <!-- 使用自定义的插件 --> <!--optional,旨在创建class时,对注释进行控制--> <commentGenerator type="com.darryl.generator.MyCommentGenerator"> <property name="suppressDate" value="true" /> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator>
<!-- oracle配置 --> <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@192.168.3.196:1521:project" userId="tom" password="admin"> <!-- 针对oracle数据库 --> <property name="remarksReporting" value="true"></property> </jdbcConnection>
<!-- mysql配置 5.X--> <!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.42:3306/huancheng" userId="root" password="******"> 针对mysql数据库 <property name="useInformationSchema" value="true"></property> </jdbcConnection> -->
<!--jdbc的数据库连接 8.X--> <!-- <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/huancheng?serverTimezone=UTC" userId="root" password="******"> </jdbcConnection> --> <!--指定生成的类型为java类型,避免数据库中number等类型字段 --> <!--默认false,把JDBC DECIMAL和 NUMERIC类型解析为Integer, 为 true时把JDBC DECIMAL和NUMERIC类型解析为java.math.BigDecimal--> <!--非必须,类型处理器,在数据库类型和java类型之间的转换控制--> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver>
<!-- targetPackage:生成的实体类所在的包 --> <!-- targetProject:生成的实体类所在的硬盘位置 --> <!--自动生成的实体的存放包路径 --> <javaModelGenerator targetPackage="com.znsd.mall.bean" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <!-- 是否允许子包 --> <property name="enableSubPackages" value="true" /> <!-- 是否清理从数据库中查询出的字符串左右两边的空白字符 --> <property name="trimStrings" value="true" />
<!-- 是否对modal添加构造函数 --> <property name="constructorBased" value="true" />
<!-- 建立modal对象是否不可改变 即生成的modal对象不会有setter方法,只有构造方法 --> <property name="immutable" value="false" /> </javaModelGenerator> <!--自动生成的*Mapper.xml文件存放路径 --> <sqlMapGenerator targetPackage="com.znsd.mall.dao.mapper" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <!-- 针对数据库的一个配置,是否把 schema 作为字包名 --> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!--自动生成的*Mapper.java存放路径 --> <javaClientGenerator targetPackage="com.znsd.mall.dao.mapper" type="XMLMAPPER" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!--不生成帮助类(Exmaples) --> <!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" --> <!--已生成的表 <table schema="demo" tableName="USER" domainObjectName="User"></table> --> <!-- <table schema="" tableName="t_additional_comment" domainObjectName="AdditionalCommentBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="REPLY_Time" javaType="String" /> </table>
<table schema="" tableName="t_administrator" domainObjectName="AdministratorBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_application_info" domainObjectName="ApplicationInfoBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_comment" domainObjectName="CommentBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="comment_reply" javaType="String" /> </table> <table schema="" tableName="t_coupon" domainObjectName="CouponBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="start_time" javaType="String" /> <columnOverride column="end_time" javaType="String" /> </table>
<table schema="" tableName="t_depository" domainObjectName="DepositoryBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_depository_record" domainObjectName="DepositoryRecordBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="time" javaType="String" /> </table>
<table schema="" tableName="t_dictionary" domainObjectName="DictionaryBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_goods" domainObjectName="GoodsBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_goods_record" domainObjectName="GoodsRecordBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="time" javaType="String" /> </table>
<table schema="" tableName="t_goods_types" domainObjectName="GoodsTypesBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_order" domainObjectName="OrderBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="delivery_time" javaType="String" /> <columnOverride column="finish_time" javaType="String" /> <columnOverride column="closing_time" javaType="String" /> </table>
<table schema="" tableName="t_order_detail" domainObjectName="OrderDetailBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_order_logistics" domainObjectName="OrderLogisticsBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="shipments_time" javaType="String" /> <columnOverride column="delivery_time" javaType="String" /> <columnOverride column="sign_off_time" javaType="String" /> </table>
<table schema="" tableName="t_order_sales" domainObjectName="OrderSalesBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="refund_time" javaType="String" /> <columnOverride column="processing_time" javaType="String" /> </table>
<table schema="" tableName="t_ralance" domainObjectName="RalanceBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_role_info" domainObjectName="RoleInfoBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_specification" domainObjectName="SpecificationBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="t_store" domainObjectName="StoreBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> <columnOverride column="open_time" javaType="String" /> <columnOverride column="close_time" javaType="String" /> </table>
<table schema="" tableName="t_supplier" domainObjectName="SupplierBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table> --> <table schema="" tableName="T_GOODS_COLLECT" domainObjectName="GoodsCollectBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_MY_COUPON" domainObjectName="MyCouponBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_PRIVACY_PROTOCOL" domainObjectName="PrivacyProtocolBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_SHIPPING_ADDRESS" domainObjectName="ShippingAddressBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_SHOPPING_TROLLEY" domainObjectName="ShoppingTrolleyBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_STORE_COLLECT" domainObjectName="StoreCollectBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_USER_BANK" domainObjectName="UserBankBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_USER_LOGIN" domainObjectName="UserLoginBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table>
<table schema="" tableName="T_USER_PROFILE" domainObjectName="UserProfileBean" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="CREATE_Time" javaType="String" /> <columnOverride column="UPDATE_Time" javaType="String" /> </table> </context> </generatorConfiguration> |