package com.tzld.piaoquan.api.dao.generator;

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;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


public class ApiMybatisGeneratorMain {

    public static void main(String[] args)
            throws SQLException, IOException, InterruptedException, InvalidConfigurationException, XMLParserException {
        List<String> warnings = new ArrayList<>();

        File configFile = new File(ApiMybatisGeneratorMain.class.getResource("/mybatis-api-generator-config.xml").getFile());
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(configFile);
        DefaultShellCallback callback = new DefaultShellCallback(true);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        myBatisGenerator.generate(null);
        System.out.println("genreate finish");
    }
}
