标签:type text ring res exce 自动 file get gen
<?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="mysqlTables" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- 数据库连接 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/test?characterEncoding=UTF-8"
userId="root"
password="#####"/>
<!--指定生成的类型为java类型,避免数据库中number等类型字段 -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!--自动生成的实体的存放包路径-->
<javaModelGenerator targetPackage="com.pojo" targetProject="d:/">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!--自动生成的*Mapper.xml文件存放路径 -->
<sqlMapGenerator targetPackage="mappers" targetProject="d:/">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!--自动生成的*Mapper.java存放路径 -->
<!-- <javaClientGenerator type="XMLMAPPER" targetPackage="com.mapper" targetProject="src/main/java">-->
<!-- <property name="enableSubPackages" value="true"/>-->
<!-- </javaClientGenerator>-->
<table tableName="Crj_Apply_Journey" domainObjectName="CrjApplyJourney" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
</table>
</context>
<!-- <table tableName="crj_cabinet_type" domainObjectName="CrjCabinetType" enableCountByExample="false" enableUpdateByExample="false"-->
<!-- enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
<!-- </table>-->
<!-- <table tableName="crj_permission" domainObjectName="CrjPermission" enableCountByExample="false" enableUpdateByExample="false"-->
<!-- enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
<!-- </table>-->
<!-- <table tableName="crj_certificate" domainObjectName="CrjCertificate" enableCountByExample="false" enableUpdateByExample="false"-->
<!-- enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
<!-- </table>-->
<!-- <table tableName="crj_department" domainObjectName="CrjDepartment" enableCountByExample="false" enableUpdateByExample="false"-->
<!-- enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
<!-- </table>-->
<!-- <table tableName="crj_role" domainObjectName="CrjRole" enableCountByExample="false" enableUpdateByExample="false"-->
<!-- enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
<!-- </table>-->
</generatorConfiguration>
package com.util;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* 描述:
* <p>
* author caoxiaoyang
* date 2021-04-27
* version
*/
public class GenUtils {
public static void main(String[] args) {
try {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
String genCfg = "generatorConfig.xml";
//D:\java\src\main\resources\generatorConfig.xml
File configFile = new File("D:\\java\\\\main\\resources\\generatorConfig.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = null;
config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = null;
myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
标签:type text ring res exce 自动 file get gen
原文地址:https://www.cnblogs.com/CAOXIAOYANG/p/14710039.html