mybatis-plus反向工程

代码如下

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.mysql.cj.jdbc.Driver;

public class MybatisPlusGenerator {

    public static void main(String[] args) {
        new AutoGenerator()
                .setDataSource(dataSourceConfig())
                .setPackageInfo(packageConfig())
                .setStrategy(strategyConfig())
                .setGlobalConfig(globalConfig())
                .execute();
    }

    private static GlobalConfig globalConfig() {
        return new GlobalConfig()
                .setFileOverride(true)
                .setSwagger2(true)
                .setAuthor("author")
                .setOpen(false)
                .setOutputDir("src\\test\\java");
    }

    private static StrategyConfig strategyConfig() {
        return new StrategyConfig()
                .setEntityLombokModel(true)
                .setNaming(NamingStrategy.underline_to_camel)
                .setEntitySerialVersionUID(false)
                .setInclude("user");
    }

    private static PackageConfig packageConfig() {
        return new PackageConfig()
                .setParent("com.user");
    }

    private static DataSourceConfig dataSourceConfig() {
        return new DataSourceConfig()
                .setUsername("root")
                .setPassword("123456")
                .setDbType(DbType.MYSQL)
                .setDriverName(Driver.class.getName())
                .setUrl("jdbc:mysql://localhost:3306/test");
    }

引用

        <dependency>
            <groupId>com.baomidougroupId>
            <artifactId>mybatis-plus-generatorartifactId>
            <version>3.4.0version>
            <scope>providedscope>
        dependency>
        <dependency>
            <groupId>org.apache.velocitygroupId>
            <artifactId>velocityartifactId>
            <version>1.6.4version>
            <scope>providedscope>
        dependency>

你可能感兴趣的:(mybatis)