|
@@ -1,4 +1,4 @@
|
|
|
-package com.usky.demo.controller;//package com.usky.demo.controller;//package com.usky.dm.controller.web.business;//package com.usky.dm.controller.web;
|
|
|
+package com.usky.demo.biz.controller;//package com.usky.demo.controller;//package com.usky.dm.controller.web.business;//package com.usky.dm.controller.web;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
|
@@ -18,17 +18,20 @@ import java.util.List;
|
|
|
public class MybatisGeneratorUtils {
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
- shell("usky-modules-demo-biz");
|
|
|
+ shell("usky-module-demo","usky-module-demo-biz");
|
|
|
}
|
|
|
|
|
|
- private static void shell(String model) {
|
|
|
+ private static void shell(String parentName,String model) {
|
|
|
|
|
|
AutoGenerator mpg = new AutoGenerator();
|
|
|
//1、全局配置
|
|
|
GlobalConfig gc = new GlobalConfig();
|
|
|
- File file = new File(model);
|
|
|
- String path = file.getAbsolutePath();
|
|
|
- gc.setOutputDir(path + "/src/main/java"); //生成路径(一般都是生成在此项目的src/main/java下面)
|
|
|
+// File file = new File(model);
|
|
|
+// String path = file.getAbsolutePath();
|
|
|
+ String projectPath = System.getProperty("user.dir");
|
|
|
+ projectPath+="/"+parentName;
|
|
|
+ projectPath+="/"+model;
|
|
|
+ gc.setOutputDir(projectPath+ "/src/main/java"); //生成路径(一般都是生成在此项目的src/main/java下面)
|
|
|
//修改为自己的名字
|
|
|
gc.setAuthor("ya"); //设置作者
|
|
|
gc.setOpen(false);
|
|
@@ -48,7 +51,7 @@ public class MybatisGeneratorUtils {
|
|
|
|
|
|
// 3、包配置
|
|
|
PackageConfig pc = new PackageConfig();
|
|
|
- pc.setParent("com.usky.demo");
|
|
|
+ pc.setParent("com.usky.demo.biz");
|
|
|
pc.setController("controller.web");
|
|
|
pc.setEntity("domain");
|
|
|
pc.setMapper("mapper");
|
|
@@ -86,11 +89,12 @@ public class MybatisGeneratorUtils {
|
|
|
// 自定义输出配置
|
|
|
List<FileOutConfig> focList = new ArrayList<>();
|
|
|
// 自定义配置会被优先输出
|
|
|
+ String finalProjectPath = projectPath;
|
|
|
focList.add(new FileOutConfig(templatePath) {
|
|
|
@Override
|
|
|
public String outputFile(TableInfo tableInfo) {
|
|
|
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
|
|
|
- return path + "/src/main/resources/mapper.demo" + "/"
|
|
|
+ return finalProjectPath + "/src/main/resources/mapper.demo" + "/"
|
|
|
+ tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
|
|
|
}
|
|
|
});
|