mybatis-gennerator-extend插件开发完毕
This commit is contained in:
+14
-1
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mybatis-generator-extend-maven-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<name>mybatis-generator-extend</name>
|
||||
<description>mybatis-generator-extend-maven-plugin</description>
|
||||
@@ -15,6 +15,7 @@
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!--micro-fast-工具类依赖-->
|
||||
<dependency>
|
||||
<groupId>com.micro.fast</groupId>
|
||||
<artifactId>boot-starter-util</artifactId>
|
||||
@@ -38,6 +39,18 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<!--maven-plugin插件开发依赖-->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
<version>3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.micro.fast.mybatis.generator.extend.mojo;
|
||||
|
||||
import com.micro.fast.mybatis.generator.extend.service.MybatisGeneratorExtend;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
|
||||
/**
|
||||
* maven插件执行主类
|
||||
*/
|
||||
@Mojo(name = "generateFiles")
|
||||
public class MyabtisGeneratorExtendMojo extends AbstractMojo {
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
MybatisGeneratorExtend.GenerateMybatisGeneratorNeedFilesByTemplates();
|
||||
}
|
||||
}
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package com.micro.fast.mybatis.generator.extend.pojo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
+3
-7
@@ -66,11 +66,7 @@ public class MybatisGeneratorExtend {
|
||||
String firstUpper = string.replaceFirst(s, upperCase);
|
||||
doMainObjectName += firstUpper;
|
||||
}
|
||||
char c = tableName.charAt(0);
|
||||
String s = String.valueOf(c);
|
||||
String upperCase = s.toUpperCase();
|
||||
String firstUpperDoMainObjectName = doMainObjectName.replaceFirst(s, upperCase);
|
||||
tablesNameAndDoMainObjectsName.put(tableName,firstUpperDoMainObjectName);
|
||||
tablesNameAndDoMainObjectsName.put(tableName,doMainObjectName);
|
||||
}
|
||||
}
|
||||
MybatisGeneratorExtend.mybatisGenerator.setTablesNameAndDoMainObjectsName(tablesNameAndDoMainObjectsName);
|
||||
@@ -78,8 +74,8 @@ public class MybatisGeneratorExtend {
|
||||
Map<String,Object> mybatisGeneratorModel = new HashMap<>();
|
||||
mybatisGeneratorModel.put("db",MybatisGeneratorExtend.db);
|
||||
mybatisGeneratorModel.put("mybatisGenerator",MybatisGeneratorExtend.mybatisGenerator);
|
||||
boolean mybatisGeneratorFileSuccess = FreemarkerUtil.createFile("mybatisGenerator.fm", mybatisGeneratorModel, "mybatisGenerator.properties");
|
||||
boolean generatorConfigFileSuccess = FreemarkerUtil.createFile("generatorConfig.fm", mybatisGeneratorModel, "generatorConfig.xml");
|
||||
boolean mybatisGeneratorFileSuccess = FreemarkerUtil.createFile("mybatisGenerator.ftl", mybatisGeneratorModel, "mybatisGenerator.properties");
|
||||
boolean generatorConfigFileSuccess = FreemarkerUtil.createFile("generatorConfig.ftl", mybatisGeneratorModel, "generatorConfig.xml");
|
||||
} catch (SQLException e) {
|
||||
log.error("错误{} {}", e, "sql语句执行失败");
|
||||
e.printStackTrace();
|
||||
|
||||
+2
-11
@@ -66,17 +66,8 @@
|
||||
<!-- enableSubPackages:是否让schema作为包的后缀 -->
|
||||
<property name="enableSubPackages" value="false" />
|
||||
</javaClientGenerator>
|
||||
<#list mybatisGenerator.tablesName as >
|
||||
<#list mybatisGenerator.tablesNameAndDoMainObjectsName?keys as key >
|
||||
<table tableName="${key}" domainObjectName="${mybatisGenerator.tablesNameAndDoMainObjectsName.get(key)}" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
</#list>
|
||||
<table tableName="upms_log" domainObjectName="UpmsLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_organization" domainObjectName="UpmsOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_permission" domainObjectName="UpmsPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_role" domainObjectName="UpmsRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_role_permission" domainObjectName="UpmsRolePermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="system" domainObjectName="System" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_user" domainObjectName="UpmsUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_user_organization" domainObjectName="UpmsUserOrganization" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_user_permission" domainObjectName="UpmsUserPermission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
<table tableName="upms_user_role" domainObjectName="UpmsUserRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
@@ -118,6 +118,7 @@
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<!--冗余的-->
|
||||
<verbose>true</verbose>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
|
||||
Reference in New Issue
Block a user