Mybatis Plus 逆向工程介绍

一、创建数据库

Mybatis Plus 逆向工程介绍_第1张图片

二、配置pom.xml 文件

   
        org.mybatis.generator
        mybatis-generator-core
        1.3.5
    

导入mybatis-generator的jar包:

Mybatis Plus 逆向工程介绍_第2张图片

注:如果存在导入不进去的情况

在项目-右键-maven-updataproject

Mybatis Plus 逆向工程介绍_第3张图片

三、在项目同级目录建立mgb.xml





  
  
    
        
    
    
    
    

    
      
    
     
     
    
      
      
    
     
     
     
    
      
    
    
    
    
    
      
    
    
    
    
    
     
 

四、在测试类中写入方法

package com.crud.text;

import java.io.File;
import java.util.ArrayList;
import java.util.List;


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;

public class MGBTest {
    public static void main(String[] args) throws Exception {
         List warnings = new ArrayList();
           boolean overwrite = true;
           //下面写入自己建立的xml文件
           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);
  }
}

刷新项目(按F5)

Mybatis Plus 逆向工程介绍_第4张图片

如同对应就生产好了。

到此这篇关于Mybatis Plus 逆向工程介绍的文章就介绍到这了,更多相关Mybatis Plus 逆向工程内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

你可能感兴趣的:(Mybatis Plus 逆向工程介绍)