Skip to content

Commit

Permalink
修复代码生成器非windows系统下模板路径问题
Browse files Browse the repository at this point in the history
  • Loading branch information
shuzheng committed Oct 24, 2017
1 parent 5a501a6 commit 1f9068d
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@ public static void generator(
String package_name,
Map<String, String> last_insert_id_tables) throws Exception{

generatorConfig_vm = MybatisGeneratorUtil.class.getResource(generatorConfig_vm).getPath().replaceFirst("/", "");
service_vm = MybatisGeneratorUtil.class.getResource(service_vm).getPath().replaceFirst("/", "");
serviceMock_vm = MybatisGeneratorUtil.class.getResource(serviceMock_vm).getPath().replaceFirst("/", "");
serviceImpl_vm = MybatisGeneratorUtil.class.getResource(serviceImpl_vm).getPath().replaceFirst("/", "");
String os = System.getProperty("os.name");
if (os.toLowerCase().startsWith("win")) {
generatorConfig_vm = MybatisGeneratorUtil.class.getResource(generatorConfig_vm).getPath().replaceFirst("/", "");
service_vm = MybatisGeneratorUtil.class.getResource(service_vm).getPath().replaceFirst("/", "");
serviceMock_vm = MybatisGeneratorUtil.class.getResource(serviceMock_vm).getPath().replaceFirst("/", "");
serviceImpl_vm = MybatisGeneratorUtil.class.getResource(serviceImpl_vm).getPath().replaceFirst("/", "");
} else {
generatorConfig_vm = MybatisGeneratorUtil.class.getResource(generatorConfig_vm).getPath();
service_vm = MybatisGeneratorUtil.class.getResource(service_vm).getPath();
serviceMock_vm = MybatisGeneratorUtil.class.getResource(serviceMock_vm).getPath();
serviceImpl_vm = MybatisGeneratorUtil.class.getResource(serviceImpl_vm).getPath();
}

String targetProject = module + "/" + module + "-dao";
String basePath = MybatisGeneratorUtil.class.getResource("/").getPath().replace("/target/classes/", "").replace(targetProject, "").replaceFirst("/", "");
Expand Down Expand Up @@ -153,9 +161,6 @@ public static void generator(
}
}
System.out.println("========== 结束生成Service ==========");

System.out.println("========== 开始生成Controller ==========");
System.out.println("========== 结束生成Controller ==========");
}

// 递归删除非空文件夹
Expand Down

0 comments on commit 1f9068d

Please sign in to comment.