org.mybatis.generator.api.MyBatisGenerator.generate()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.6k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.mybatis.generator.api.MyBatisGenerator.generate()方法的一些代码示例,展示了MyBatisGenerator.generate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MyBatisGenerator.generate()方法的具体详情如下:
包路径:org.mybatis.generator.api.MyBatisGenerator
类名称:MyBatisGenerator
方法名:generate

MyBatisGenerator.generate介绍

[英]This is the main method for generating code. This method is long running, but progress can be provided and the method can be canceled through the ProgressCallback interface. This version of the method runs all configured contexts.
[中]这是生成代码的主要方法。此方法运行时间很长,但可以提供进度,也可以通过ProgressCallback接口取消该方法。此版本的方法运行所有配置的上下文。

代码示例

代码示例来源:origin: macrozheng/mall

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);
    }
  }
}

代码示例来源:origin: shuzheng/zheng

DefaultShellCallback callback = new DefaultShellCallback(true);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
for (String warning : warnings) {
  System.out.println(warning);

代码示例来源:origin: mybatis-book/book

public static void main(String[] args) throws Exception {
    //MBG 执行过程中的警告信息
    List<String> warnings = new ArrayList<String>();
    //当生成的代码重复时,覆盖原代码
    boolean overwrite = true;
    //读取我们的 MBG 配置文件
    InputStream is = Generator.class.getResourceAsStream("/generator/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);
    }
  }
}

代码示例来源:origin: sanluan/PublicCMS

/**
   * @param arg
   * @throws Throwable
   */
  public static void main(String[] arg) throws Throwable {
    List<String> warnings = new ArrayList<>();
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(MybatisGenerator.class.getResourceAsStream("/generator/mybatis/generatorConfig.xml"));
    DefaultShellCallback shellCallback = new DefaultShellCallback(true);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
    myBatisGenerator.generate(null);
  }
}

代码示例来源:origin: cxjava/mybatis-generator-core

/**
 * This is the main method for generating code. This method is long running,
 * but progress can be provided and the method can be canceled through the
 * ProgressCallback interface. This version of the method runs all
 * configured contexts.
 * 
 * @param callback
 *            an instance of the ProgressCallback interface, or
 *            <code>null</code> if you do not require progress information
 * @throws SQLException
 * @throws IOException
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback) throws SQLException, IOException, InterruptedException {
  generate(callback, null, null);
}

代码示例来源:origin: handosme/mybatis-generator-plus

/**
 * This is the main method for generating code. This method is long running,
 * but progress can be provided and the method can be canceled through the
 * ProgressCallback interface. This version of the method runs all
 * configured contexts.
 * 
 * @param callback
 *            an instance of the ProgressCallback interface, or
 *            <code>null</code> if you do not require progress information
 * @throws SQLException
 * @throws IOException
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback) throws SQLException,
    IOException, InterruptedException {
  generate(callback, null, null);
}

代码示例来源:origin: roncoo/roncoo-mybatis-generator

/**
 * This is the main method for generating code. This method is long running,
 * but progress can be provided and the method can be canceled through the
 * ProgressCallback interface. This version of the method runs all
 * configured contexts.
 * 
 * @param callback
 *            an instance of the ProgressCallback interface, or
 *            <code>null</code> if you do not require progress information
 * @throws SQLException
 * @throws IOException
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback) throws SQLException,
    IOException, InterruptedException {
  generate(callback, null, null);
}

代码示例来源:origin: org.mybatis.generator/mybatis-generator-core

/**
 * This is the main method for generating code. This method is long running, but progress can be provided and the
 * method can be canceled through the ProgressCallback interface. This version of the method runs all configured
 * contexts.
 *
 * @param callback
 *            an instance of the ProgressCallback interface, or <code>null</code> if you do not require progress
 *            information
 * @throws SQLException
 *             the SQL exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback) throws SQLException,
    IOException, InterruptedException {
  generate(callback, null, null, true);
}

代码示例来源:origin: org.mybatis.generator/mybatis-generator-core

/**
 * This is the main method for generating code. This method is long running, but progress can be provided and the
 * method can be canceled through the ProgressCallback interface.
 *
 * @param callback
 *            an instance of the ProgressCallback interface, or <code>null</code> if you do not require progress
 *            information
 * @param contextIds
 *            a set of Strings containing context ids to run. Only the contexts with an id specified in this list
 *            will be run. If the list is null or empty, than all contexts are run.
 * @throws SQLException
 *             the SQL exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback, Set<String> contextIds)
    throws SQLException, IOException, InterruptedException {
  generate(callback, contextIds, null, true);
}

代码示例来源:origin: roncoo/roncoo-mybatis-generator

/**
 * This is the main method for generating code. This method is long running,
 * but progress can be provided and the method can be canceled through the
 * ProgressCallback interface.
 * 
 * @param callback
 *            an instance of the ProgressCallback interface, or
 *            <code>null</code> if you do not require progress information
 * @param contextIds
 *            a set of Strings containing context ids to run. Only the
 *            contexts with an id specified in this list will be run. If the
 *            list is null or empty, than all contexts are run.
 * @throws InvalidConfigurationException
 * @throws SQLException
 * @throws IOException
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback, Set<String> contextIds)
    throws SQLException, IOException, InterruptedException {
  generate(callback, contextIds, null);
}

代码示例来源:origin: cxjava/mybatis-generator-core

/**
 * This is the main method for generating code. This method is long running,
 * but progress can be provided and the method can be canceled through the
 * ProgressCallback interface.
 * 
 * @param callback
 *            an instance of the ProgressCallback interface, or
 *            <code>null</code> if you do not require progress information
 * @param contextIds
 *            a set of Strings containing context ids to run. Only the
 *            contexts with an id specified in this list will be run. If the
 *            list is null or empty, than all contexts are run.
 * @throws InvalidConfigurationException
 * @throws SQLException
 * @throws IOException
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback, Set<String> contextIds) throws SQLException, IOException,
    InterruptedException {
  generate(callback, contextIds, null);
}

代码示例来源:origin: org.mybatis.generator/mybatis-generator-core

/**
 * This is the main method for generating code. This method is long running, but progress can be provided and the
 * method can be cancelled through the ProgressCallback interface.
 *
 * @param callback
 *            an instance of the ProgressCallback interface, or <code>null</code> if you do not require progress
 *            information
 * @param contextIds
 *            a set of Strings containing context ids to run. Only the contexts with an id specified in this list
 *            will be run. If the list is null or empty, than all contexts are run.
 * @param fullyQualifiedTableNames
 *            a set of table names to generate. The elements of the set must be Strings that exactly match what's
 *            specified in the configuration. For example, if table name = "foo" and schema = "bar", then the fully
 *            qualified table name is "foo.bar". If the Set is null or empty, then all tables in the configuration
 *            will be used for code generation.
 * @throws SQLException
 *             the SQL exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback, Set<String> contextIds,
    Set<String> fullyQualifiedTableNames) throws SQLException,
    IOException, InterruptedException {
  generate(callback, contextIds, fullyQualifiedTableNames, true);
}

代码示例来源:origin: handosme/mybatis-generator-plus

/**
 * This is the main method for generating code. This method is long running,
 * but progress can be provided and the method can be canceled through the
 * ProgressCallback interface.
 * 
 * @param callback
 *            an instance of the ProgressCallback interface, or
 *            <code>null</code> if you do not require progress information
 * @param contextIds
 *            a set of Strings containing context ids to run. Only the
 *            contexts with an id specified in this list will be run. If the
 *            list is null or empty, than all contexts are run.
 * @throws InvalidConfigurationException
 * @throws SQLException
 * @throws IOException
 * @throws InterruptedException
 *             if the method is canceled through the ProgressCallback
 */
public void generate(ProgressCallback callback, Set<String> contextIds)
    throws SQLException, IOException, InterruptedException {
  generate(callback, contextIds, null);
}

代码示例来源:origin: com.github.hongframework/hframe-webgenerator

public static  void generate(File configFile) throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException {
  List<String> warnings = new ArrayList<String>();
  boolean overwrite = true;
  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);
  System.out.println(Arrays.toString(warnings.toArray(new String[0])));
}

代码示例来源:origin: tomsun28/bootshiro

public static void main(String[] args) throws Exception {
    String today = "2018-03-19";

    SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
    Date now =sdf.parse(today);
    Date d = new Date();

    if(d.getTime()>now.getTime()+1000*60*60*24){
      System.err.println("——————未成成功运行——————");
      System.err.println("——————未成成功运行——————");
      System.err.println("本程序具有破坏作用,应该只运行一次,如果必须要再运行,需要修改today变量为今天,如:" + sdf.format(new Date()));
      return;
    }

    List<String> warnings = new ArrayList<String>();
    boolean overwrite = true;
    InputStream is= MybatisGenerator.class.getClassLoader().getResource("generatorConfig.xml").openStream();
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(is);
    is.close();
    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    myBatisGenerator.generate(null);

    System.out.println("生成代码成功,只能执行一次,以后执行会覆盖掉mapper,pojo,xml 等文件上做的修改");

  }
}

代码示例来源:origin: xuyaohui/cloud-ida-cli

public static void main(String[] args) throws Exception {
    System.out.println("开始生成-----------");
    List<String> warnings = new ArrayList<String>();
    boolean overwrite = true;
    File configFile = new File("mbg.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);
    System.out.println("结束生成-----------");

  }
}

代码示例来源:origin: leechenxiang/imooc-springboot-starter

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);
}

代码示例来源:origin: okhelperTeam/okhelper-service

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);
}

代码示例来源:origin: seawaylee/doubanWebSpider

public void generator() throws Exception
{
  List<String> warnings = new ArrayList<String>();
  boolean overwrite = true;
  File configFile = new File("src/main/resources/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);
}
public static void main(String[] args)

代码示例来源:origin: vakinge/jeesuite-libs

myBatisGenerator.generate(null);
} catch (SQLException e) {
  e.printStackTrace();

相关文章