Java Code Examples for org.mybatis.generator.config.xml.ConfigurationParser#parseConfiguration()

The following examples show how to use org.mybatis.generator.config.xml.ConfigurationParser#parseConfiguration() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: Generator.java    From server 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 8
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 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 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 11
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 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 BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
@SneakyThrows
public static void main(String[] args) {
	List<String> warnings = new ArrayList<>();
	ConfigurationParser configurationParser = new ConfigurationParser(warnings);
	Configuration configuration = configurationParser.parseConfiguration(new File(Generator.class.getResource("").getPath() + "generator.xml"));
	DefaultShellCallback callback = new DefaultShellCallback(true);
	MyBatisGenerator generator = new MyBatisGenerator(configuration, callback, warnings);
	generator.generate(new VerboseProgressCallback());
	for (String warn : warnings) {
		System.out.println(warn);
	}
}
 
Example 15
Source File: MBGTest.java    From Resource with GNU General Public License v3.0 5 votes vote down vote up
private static void run()
    throws Exception
{
    List<String> warnings = new ArrayList<String>();
    boolean overwrite = true;
    //配置MyBatis generator配置文件
    File configFile = new File("src/main/resources/mybatis-generator.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(configFile);
    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    myBatisGenerator.generate(null);
}
 
Example 16
Source File: Generator.java    From tk-mybatis with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    List<String> warnings = new ArrayList<String>();
    boolean overwrite = true;
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(
            Generator.class.getResourceAsStream("/generator/generatorConfig.xml"));
    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    myBatisGenerator.generate(null);
}
 
Example 17
Source File: SpringbootDataDrivenDemoApplication.java    From Java-API-Test-Examples with Apache License 2.0 5 votes vote down vote up
/**
 * 执行MyBatisGenerator
 * @throws Exception
 */
private void generateArtifacts() throws Exception {
    List<String> warnings = new ArrayList<>();
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(
            this.getClass().getResourceAsStream("/generatorConfig.xml"));
    DefaultShellCallback callback = new DefaultShellCallback(true);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    myBatisGenerator.generate(null);
}
 
Example 18
Source File: Generator.java    From seata-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException {
    List<String> warnings = new ArrayList<String>();
    boolean overwrite = true;
    InputStream inputStream = Generator.class.getClassLoader().getResourceAsStream("config/generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);

    Configuration config = cp.parseConfiguration(inputStream);
    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,
            callback, warnings);
    myBatisGenerator.generate(new NullProgressCallback());

}
 
Example 19
Source File: Generator.java    From mbg-comment with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    List<String> warnings = new ArrayList<>(2);
    ConfigurationParser cp = new ConfigurationParser(warnings);

    File configFile = new File("generatorConfig.xml");
    Configuration config = cp.parseConfiguration(configFile);

    DefaultShellCallback callback = new DefaultShellCallback(true);

    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    myBatisGenerator.generate(null);
}
 
Example 20
Source File: GeneratorSqlmap.java    From generatorSqlmapCustom with MIT License 5 votes vote down vote up
public void generator() throws Exception {

        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;
        //指定 逆向工程配置文件
        File configFile = new File("generatorConfig.xml");
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(configFile);
        DefaultShellCallback callback = new DefaultShellCallback(overwrite);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,
                callback, warnings);
        myBatisGenerator.generate(null);

    }