qq_44999366
qq_44999366
2021-01-21 16:58

mybatis-plus代码生成器会生成baomidou文件夹,但学习的视频都不会这样

  • java
  • maven
  • mysql
  • intellij-idea

下面是我的代码

package com.csy.springboot.mmall;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
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.po.TableFill;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import sun.security.pkcs11.Secmod;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        AutoGenerator autoGenerator = new AutoGenerator();
        DataSourceConfig dataSourceConfig = new DataSourceConfig();
        dataSourceConfig.setDbType(DbType.MYSQL);
        dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver");
        dataSourceConfig.setUsername("root");
        dataSourceConfig.setPassword("123456");
        dataSourceConfig.setUrl("jdbc:mysql://localhost:3306/mmall?useUnicode=true&characterEncoding=UTF-8");
        autoGenerator.setDataSource(dataSourceConfig);
        GlobalConfig globalConfig = new GlobalConfig();
        globalConfig.setOpen(true);
        System.out.println(System.getProperty("user.dir"));
        globalConfig.setOutputDir("D:\\桌面\\JAVA路线学习\\springBootProject\\mmall\\src\\main\\java");//从数据库中逆向生成实体类等文件,并打包成文件夹
        globalConfig.setAuthor("Baron");
        globalConfig.setServiceName("%sService");
        globalConfig.setActiveRecord(true);
        autoGenerator.setGlobalConfig(globalConfig);
        PackageConfig packageConfig = new PackageConfig();//创建文件夹配置
        packageConfig.setParent("com.csy.springboot.mmall");
        packageConfig.setEntity("entity");//实体类文件夹
        packageConfig.setMapper("mapper");//dao层文件夹
        packageConfig.setService("service");//服务层接口文件夹
        packageConfig.setServiceImpl("service.impl");//服务层实现类文件夹
        packageConfig.setController("controller");//控制层文件夹
        StrategyConfig strategyConfig = new StrategyConfig();
        strategyConfig.setEntityLombokModel(true);
        strategyConfig.setNaming(NamingStrategy.underline_to_camel);
        strategyConfig.setColumnNaming(NamingStrategy.underline_to_camel);
        List<TableFill> list = new ArrayList<>();
        TableFill tableFill1 = new TableFill("create_time",FieldFill.INSERT);
        TableFill tableFill2 = new TableFill("update_time",FieldFill.INSERT_UPDATE);
        list.add(tableFill1);
        list.add(tableFill2);
        strategyConfig.setTableFillList(list);//描述当前填充的字段
        autoGenerator.setStrategy(strategyConfig);
        autoGenerator.execute();
    }
}

 

之后他创建的目录会自动生成com/baomidou/xxx的文件夹,我不想生成这个,应该怎么办?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答