springboot mybatisGenerator只需几步快速生成对象

经常要用到MybatisGenerator反向生成ORM对象,故在springboot基础上几步快速搭建:
1、增加依赖

    compile group: 'org.mybatis.generator', name: 'mybatis-generator-core', version:'1.3.2'
    compile('com.jslsolucoes:ojdbc6:11.2.0.1.0') 
    compile group: 'org.mybatis', name: 'mybatis', version: '3.4.6'

2、书写一个xml文件,放到src\main\resources下
如我新建了一个dbConfig.xml,放在这个目录下的dbtools,内容如下:





    
    
       
           
           
       

       
       
        

       
       
           
           
       


       
       
           
           
           
           
       

       
 

       
       
           
       

       
           
           

3、在src/main/java目录下新建一个java文件,如Mybatisgenerator.java,内容如下:

package com.example.test;

import org.mybatis.generator.api.ShellRunner;

public class MybatisGenerator {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        args = new String[] { "-configfile", "src\\main\\resources\\dbtools\\dbConfig.xml", "-overwrite" };
        ShellRunner.main(args);

    }

}

4、点击java文件,采用Java Application运行该项目,大功告成,其中路径等在dbConfig.xml中进行配置就可以

你可能感兴趣的:(springboot mybatisGenerator只需几步快速生成对象)