当前位置 : 主页 > 编程语言 > java >

Mybatis Generator 插件使用demo

来源:互联网 收集:自由互联 发布时间:2021-06-28
generatorConfig.xml GeneratorMain.java package com.min;import org.mybatis.generator.api.MyBatisGenerator;import org.mybatis.generator.config.Configuration;import org.mybatis.generator.config.xml.ConfigurationParser;import org.mybatis.genera
generatorConfig.xml
 



 
    
   
    
     
     
     
    
    
    
    
    
    
   
     
    
  

 
GeneratorMain.java
package com.min;

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.util.ArrayList;
import java.util.List;

/**
 *
 * @author llx
 * @date 2017/11/30
 * 参考 https://mapperhelper.github.io/docs
 */
public class GeneratorMain {

    public static void main(String[] args) {
        List
 
   warnings = new ArrayList
  
   (); boolean overwrite = true; ConfigurationParser cp = new ConfigurationParser(warnings); try { Configuration config = cp.parseConfiguration(GeneratorMain.class.getResourceAsStream("/generatorConfig.xml")); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); myBatisGenerator.generate(null); } catch (Exception e) { e.printStackTrace(); } } }
  
 
网友评论