Mybatis Generator

pom.xml

        
            org.mybatis.generator
            mybatis-generator-core
            test
        
        
            org.mybatis
            mybatis-typehandlers-jsr310
        

generatorConfig.xml





    

    
        
        
        

        
            
        
        

        
        

        
            
            
        

        

        

        


        

        
        
        
        
        
        


    

generatorConfig.properties

# 数据库配置
jdbc.driverClass                = com.mysql.cj.jdbc.Driver
jdbc.url                        = jdbc:mysql://192.168.1.201:13306/hhw_dev?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
jdbc.user                       = hhw_dev
jdbc.password                   = mysql:hhw_dev:4f0LFwIPSp8Iyogk
#c3p0
jdbc.maxPoolSize                = 50
jdbc.minPoolSize                = 10
jdbc.maxStatements              = 100
jdbc.testConnection             = true
# 通用Mapper配置
mapper.plugin                   = tk.mybatis.mapper.generator.MapperPlugin
mapper.Mapper                   = com.hehewang.hhw.app.common.util.ApiMapper

# domain
targetModelPackage              = com.hehewang.hhw.app.common.dao
# mapper
targetMapperPackage             = com.hehewang.hhw.app.common.mapper

targetJavaProject               = app-common/src/main/java
targetResourcesProject          = app-common/src/main/resources

MybatisGeneratorRun.java

package xxx.app.common.generator;

import org.mybatis.generator.api.ShellRunner;

import java.io.IOException;

public class MybatisGeneratorRun
{
    public static void main(String[] args) throws IOException, InterruptedException
    {
        // 生成dao文件
        args = new String[] { "-configfile", "app-common/src/test/resources/generatorConfig.xml", "-overwrite" };
        ShellRunner.main(args);

        // 备份 TODO Mysql服务器升级
//        MySqlDumpTest dump = new MySqlDumpTest();
//        dump.before();
//        dump.bumpSchema();// 结构
//        dump.bumpData();// 数据
    }
}

你可能感兴趣的