org.mybatis.generator.config.Configuration Java Examples

The following examples show how to use org.mybatis.generator.config.Configuration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #2
Source File: IbatorConfigurationParser.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
public Configuration parseIbatorConfiguration(Element rootNode)
        throws XMLParserException {

    Configuration configuration = new Configuration();

    NodeList nodeList = rootNode.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("properties".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperties(configuration, childNode);
        } else if ("classPathEntry".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseClassPathEntry(configuration, childNode);
        } else if ("ibatorContext".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseIbatorContext(configuration, childNode);
        }
    }

    return configuration;
}
 
Example #3
Source File: IbatorConfigurationParser.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
public Configuration parseIbatorConfiguration(Element rootNode)
        throws XMLParserException {

    Configuration configuration = new Configuration();

    NodeList nodeList = rootNode.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("properties".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperties(configuration, childNode);
        } else if ("classPathEntry".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseClassPathEntry(configuration, childNode);
        } else if ("ibatorContext".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseIbatorContext(configuration, childNode);
        }
    }

    return configuration;
}
 
Example #4
Source File: Generator.java    From HIS with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #5
Source File: Generator.java    From HIS with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #6
Source File: Generator.java    From HIS with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #7
Source File: MyBatisGeneratorConfigurationParser.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
public Configuration parseConfiguration(Element rootNode)
        throws XMLParserException {

    Configuration configuration = new Configuration();

    NodeList nodeList = rootNode.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("properties".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperties(configuration, childNode);
        } else if ("classPathEntry".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseClassPathEntry(configuration, childNode);
        } else if ("context".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseContext(configuration, childNode);
        }
    }

    return configuration;
}
 
Example #8
Source File: Generator.java    From HIS with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #9
Source File: Generator.java    From HIS with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #10
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #11
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #12
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #13
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #14
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #15
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #16
Source File: Generator.java    From mall-tiny with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #17
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #18
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #19
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #20
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #21
Source File: Generator.java    From mall-learning with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #22
Source File: MySqlMybatisGenerator.java    From java-master with Apache License 2.0 6 votes vote down vote up
public static void generator() throws Exception {
    List<String> warnings = new ArrayList<>();
    File propFile = ResourceUtils.getFile("classpath:generatorConfig.properties");
    Properties properties = new Properties();
    properties.load(new FileInputStream(propFile));

    String projectPath = new File("").getAbsolutePath();
    properties.put("project.path", projectPath);


    InputStream inputStream = addTableToXml(properties.getProperty("tables"));

    ConfigurationParser cp = new ConfigurationParser(properties, warnings);
    Configuration config = cp.parseConfiguration(inputStream);
    DefaultShellCallback callback = new DefaultShellCallback(true);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    myBatisGenerator.generate(null);
    inputStream.close();
    logger.info("generated warnings:" + warnings);
}
 
Example #23
Source File: Generator.java    From xmall with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #24
Source File: MyBatisGeneratorTool.java    From mybatis-generator-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 获取SqlSession
 * @return
 * @throws IOException
 */
public SqlSession getSqlSession() throws IOException, ClassNotFoundException {
    org.apache.ibatis.session.Configuration config = new org.apache.ibatis.session.Configuration();
    config.setCallSettersOnNulls(true); // 设计null调用setter方法
    config.setMapUnderscoreToCamelCase(true);   // 驼峰命名支持

    // 设置mapper
    config.addMappers(targetPackage);
    // 设置数据源,事务
    PooledDataSourceFactory dataSourceFactory = new PooledDataSourceFactory();
    dataSourceFactory.setProperties(DBHelper.properties);
    DataSource dataSource = dataSourceFactory.getDataSource();
    JdbcTransactionFactory transactionFactory = new JdbcTransactionFactory();

    Environment environment = new Environment("test", transactionFactory, dataSource);
    config.setEnvironment(environment);
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(config);
    return sqlSessionFactory.openSession(true);
}
 
Example #25
Source File: Generator.java    From macrozheng-mall with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #26
Source File: MyBatisGeneratorConfigurationParser.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
public Configuration parseConfiguration(Element rootNode)
        throws XMLParserException {

    Configuration configuration = new Configuration();

    NodeList nodeList = rootNode.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("properties".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperties(configuration, childNode);
        } else if ("classPathEntry".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseClassPathEntry(configuration, childNode);
        } else if ("context".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseContext(configuration, childNode);
        }
    }

    return configuration;
}
 
Example #27
Source File: MapperGeneratorStrategyBase.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
/**
 * 调用 mybatis-generator
 *
 * @param document xml
 */
protected void generateMyBatis3(Document document, GeneratorConfig generatorConfig) {
    List<String> warnings = new ArrayList<>();
    ConfigurationParser cp = new ConfigurationParser(warnings);
    try {
        Configuration config = cp.parseConfiguration(document);

        MyShellCallback shellCallback = new MyShellCallback(true, generatorConfig.isUseMerge());

        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
        myBatisGenerator.generate(null, null, null);
    } catch (InvalidConfigurationException | XMLParserException | InterruptedException | IOException | SQLException e) {
        log.error("生成mapper error", e);
        throw new BizException("导出失败");
    }

    if (!warnings.isEmpty()) {
        warnings.forEach(log::warn);
    }
}
 
Example #28
Source File: Generator.java    From mall-swarm with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #29
Source File: Generator.java    From mall with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}
 
Example #30
Source File: Generator.java    From macrozheng with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();

    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    //创建 MBG
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    //执行生成代码
    myBatisGenerator.generate(null);
    //输出警告信息
    for (String warning : warnings) {
        System.out.println(warning);
    }
}