Просмотр исходного кода

支持自定义径生成各个模块的路径

hubin 7 лет назад
Родитель
Сommit
c181b5ea3d

+ 35 - 40
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/ConstVal.java

@@ -18,55 +18,50 @@ package com.baomidou.mybatisplus.generator.config;
 import java.nio.charset.Charset;
 
 /**
+ * <p>
  * 定义常量
+ * </p>
  *
- * @author YangHu, tangguo
- * @since 2016/8/31
+ * @author YangHu, tangguo, hubin
+ * @since 2016-08-31
  */
-public class ConstVal {
-
-    public static final String MODULENAME = "ModuleName";
-
-    public static final String ENTITY = "Entity";
-    public static final String SERVICE = "Service";
-    public static final String SERVICEIMPL = "ServiceImpl";
-    public static final String MAPPER = "Mapper";
-    public static final String XML = "Xml";
-    public static final String CONTROLLER = "Controller";
+public interface ConstVal {
 
-    public static final String ENTITY_PATH = "entity_path";
-    public static final String SERVICE_PATH = "service_path";
-    public static final String SERVICEIMPL_PATH = "serviceimpl_path";
-    public static final String MAPPER_PATH = "mapper_path";
-    public static final String XML_PATH = "xml_path";
-    public static final String CONTROLLER_PATH = "controller_path";
+    String ENTITY = "Entity";
+    String SERVICE = "Service";
+    String SERVICE_IMPL = "ServiceImpl";
+    String MAPPER = "Mapper";
+    String XML = "Xml";
+    String CONTROLLER = "Controller";
 
-    public static final String JAVA_TMPDIR = "java.io.tmpdir";
-    public static final String UTF8 = Charset.forName("UTF-8").name();
-    public static final String UNDERLINE = "_";
+    String ENTITY_PATH = "entity_path";
+    String SERVICE_PATH = "service_path";
+    String SERVICE_IMPL_PATH = "service_impl_path";
+    String MAPPER_PATH = "mapper_path";
+    String XML_PATH = "xml_path";
+    String CONTROLLER_PATH = "controller_path";
 
-    public static final String JAVA_SUFFIX = ".java";
-    public static final String KT_SUFFIX = ".kt";
-    public static final String XML_SUFFIX = ".xml";
+    String JAVA_TMPDIR = "java.io.tmpdir";
+    String UTF8 = Charset.forName("UTF-8").name();
+    String UNDERLINE = "_";
 
-    public static final String TEMPLATE_ENTITY_JAVA = "/templates/entity.java";
-    public static final String TEMPLATE_ENTITY_KT = "/templates/entity.kt";
-    public static final String TEMPLATE_MAPPER = "/templates/mapper.java";
-    public static final String TEMPLATE_XML = "/templates/mapper.xml";
-    public static final String TEMPLATE_SERVICE = "/templates/service.java";
-    public static final String TEMPLATE_SERVICEIMPL = "/templates/serviceImpl.java";
-    public static final String TEMPLATE_CONTROLLER = "/templates/controller.java";
+    String JAVA_SUFFIX = ".java";
+    String KT_SUFFIX = ".kt";
+    String XML_SUFFIX = ".xml";
 
-    public static final String VM_LOADPATH_KEY = "file.resource.loader.class";
-    public static final String VM_LOADPATH_VALUE = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader";
+    String TEMPLATE_ENTITY_JAVA = "/templates/entity.java";
+    String TEMPLATE_ENTITY_KT = "/templates/entity.kt";
+    String TEMPLATE_MAPPER = "/templates/mapper.java";
+    String TEMPLATE_XML = "/templates/mapper.xml";
+    String TEMPLATE_SERVICE = "/templates/service.java";
+    String TEMPLATE_SERVICE_IMPL = "/templates/serviceImpl.java";
+    String TEMPLATE_CONTROLLER = "/templates/controller.java";
 
-    public static final String SUPERD_MAPPER_CLASS = "com.baomidou.mybatisplus.core.mapper.BaseMapper";
-    public static final String SUPERD_SERVICE_CLASS = "com.baomidou.mybatisplus.extension.service.IService";
-    public static final String SUPERD_SERVICEIMPL_CLASS = "com.baomidou.mybatisplus.extension.service.impl.ServiceImpl";
+    String VM_LOAD_PATH_KEY = "file.resource.loader.class";
+    String VM_LOAD_PATH_VALUE = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader";
 
-    /**
-     * 输出相关常量
-     */
-    public static final String OUT_CONFIG = "config";
+    String SUPER_MAPPER_CLASS = "com.baomidou.mybatisplus.core.mapper.BaseMapper";
+    String SUPER_SERVICE_CLASS = "com.baomidou.mybatisplus.extension.service.IService";
+    String SUPER_SERVICE_IMPL_CLASS = "com.baomidou.mybatisplus.extension.service.impl.ServiceImpl";
 
 }

+ 4 - 4
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/StrategyConfig.java

@@ -79,17 +79,17 @@ public class StrategyConfig {
     /**
      * 自定义继承的Mapper类全称,带包名
      */
-    private String superMapperClass = ConstVal.SUPERD_MAPPER_CLASS;
+    private String superMapperClass = ConstVal.SUPER_MAPPER_CLASS;
 
     /**
      * 自定义继承的Service类全称,带包名
      */
-    private String superServiceClass = ConstVal.SUPERD_SERVICE_CLASS;
+    private String superServiceClass = ConstVal.SUPER_SERVICE_CLASS;
 
     /**
      * 自定义继承的ServiceImpl类全称,带包名
      */
-    private String superServiceImplClass = ConstVal.SUPERD_SERVICEIMPL_CLASS;
+    private String superServiceImplClass = ConstVal.SUPER_SERVICE_IMPL_CLASS;
 
     /**
      * 自定义继承的Controller类全称,带包名
@@ -447,7 +447,7 @@ public class StrategyConfig {
     }
 
     public StrategyConfig entityTableFieldAnnotationEnable(boolean isEnableAnnotation) {
-        this.entityTableFieldAnnotationEnable = isEnableAnnotation;
+        entityTableFieldAnnotationEnable = isEnableAnnotation;
         return this;
     }
 

+ 1 - 1
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java

@@ -29,7 +29,7 @@ public class TemplateConfig {
 
     private String service = ConstVal.TEMPLATE_SERVICE;
 
-    private String serviceImpl = ConstVal.TEMPLATE_SERVICEIMPL;
+    private String serviceImpl = ConstVal.TEMPLATE_SERVICE_IMPL;
 
     private String mapper = ConstVal.TEMPLATE_MAPPER;
 

+ 43 - 35
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java

@@ -171,6 +171,12 @@ public class ConfigBuilder {
     }
 
 
+    public ConfigBuilder setPathInfo(Map<String, String> pathInfo) {
+        this.pathInfo = pathInfo;
+        return this;
+    }
+
+
     public String getSuperEntityClass() {
         return superEntityClass;
     }
@@ -243,34 +249,36 @@ public class ConfigBuilder {
      * @param config    PackageConfig
      */
     private void handlerPackage(TemplateConfig template, String outputDir, PackageConfig config) {
-        packageInfo = new HashMap<>(8);
-        packageInfo.put(ConstVal.MODULENAME, config.getModuleName());
-        packageInfo.put(ConstVal.ENTITY, joinPackage(config.getParent(), config.getEntity()));
-        packageInfo.put(ConstVal.MAPPER, joinPackage(config.getParent(), config.getMapper()));
-        packageInfo.put(ConstVal.XML, joinPackage(config.getParent(), config.getXml()));
-        packageInfo.put(ConstVal.SERVICE, joinPackage(config.getParent(), config.getService()));
-        packageInfo.put(ConstVal.SERVICEIMPL, joinPackage(config.getParent(), config.getServiceImpl()));
-        packageInfo.put(ConstVal.CONTROLLER, joinPackage(config.getParent(), config.getController()));
-
-        // 生成路径信息
-        pathInfo = new HashMap<>(6);
-        if (StringUtils.isNotEmpty(template.getEntity(getGlobalConfig().isKotlin()))) {
-            pathInfo.put(ConstVal.ENTITY_PATH, joinPath(outputDir, packageInfo.get(ConstVal.ENTITY)));
-        }
-        if (StringUtils.isNotEmpty(template.getMapper())) {
-            pathInfo.put(ConstVal.MAPPER_PATH, joinPath(outputDir, packageInfo.get(ConstVal.MAPPER)));
-        }
-        if (StringUtils.isNotEmpty(template.getXml())) {
-            pathInfo.put(ConstVal.XML_PATH, joinPath(outputDir, packageInfo.get(ConstVal.XML)));
-        }
-        if (StringUtils.isNotEmpty(template.getService())) {
-            pathInfo.put(ConstVal.SERVICE_PATH, joinPath(outputDir, packageInfo.get(ConstVal.SERVICE)));
-        }
-        if (StringUtils.isNotEmpty(template.getServiceImpl())) {
-            pathInfo.put(ConstVal.SERVICEIMPL_PATH, joinPath(outputDir, packageInfo.get(ConstVal.SERVICEIMPL)));
-        }
-        if (StringUtils.isNotEmpty(template.getController())) {
-            pathInfo.put(ConstVal.CONTROLLER_PATH, joinPath(outputDir, packageInfo.get(ConstVal.CONTROLLER)));
+        if (null == pathInfo) {
+            // 包信息
+            packageInfo = new HashMap<>(6);
+            packageInfo.put(ConstVal.ENTITY, joinPackage(config.getParent(), config.getEntity()));
+            packageInfo.put(ConstVal.MAPPER, joinPackage(config.getParent(), config.getMapper()));
+            packageInfo.put(ConstVal.XML, joinPackage(config.getParent(), config.getXml()));
+            packageInfo.put(ConstVal.SERVICE, joinPackage(config.getParent(), config.getService()));
+            packageInfo.put(ConstVal.SERVICE_IMPL, joinPackage(config.getParent(), config.getServiceImpl()));
+            packageInfo.put(ConstVal.CONTROLLER, joinPackage(config.getParent(), config.getController()));
+
+            // 生成路径信息
+            pathInfo = new HashMap<>(6);
+            if (StringUtils.isNotEmpty(template.getEntity(getGlobalConfig().isKotlin()))) {
+                pathInfo.put(ConstVal.ENTITY_PATH, joinPath(outputDir, packageInfo.get(ConstVal.ENTITY)));
+            }
+            if (StringUtils.isNotEmpty(template.getMapper())) {
+                pathInfo.put(ConstVal.MAPPER_PATH, joinPath(outputDir, packageInfo.get(ConstVal.MAPPER)));
+            }
+            if (StringUtils.isNotEmpty(template.getXml())) {
+                pathInfo.put(ConstVal.XML_PATH, joinPath(outputDir, packageInfo.get(ConstVal.XML)));
+            }
+            if (StringUtils.isNotEmpty(template.getService())) {
+                pathInfo.put(ConstVal.SERVICE_PATH, joinPath(outputDir, packageInfo.get(ConstVal.SERVICE)));
+            }
+            if (StringUtils.isNotEmpty(template.getServiceImpl())) {
+                pathInfo.put(ConstVal.SERVICE_IMPL_PATH, joinPath(outputDir, packageInfo.get(ConstVal.SERVICE_IMPL)));
+            }
+            if (StringUtils.isNotEmpty(template.getController())) {
+                pathInfo.put(ConstVal.CONTROLLER_PATH, joinPath(outputDir, packageInfo.get(ConstVal.CONTROLLER)));
+            }
         }
     }
 
@@ -310,17 +318,17 @@ public class ConfigBuilder {
      */
     private void processTypes(StrategyConfig config) {
         if (StringUtils.isEmpty(config.getSuperServiceClass())) {
-            superServiceClass = ConstVal.SUPERD_SERVICE_CLASS;
+            superServiceClass = ConstVal.SUPER_SERVICE_CLASS;
         } else {
             superServiceClass = config.getSuperServiceClass();
         }
         if (StringUtils.isEmpty(config.getSuperServiceImplClass())) {
-            superServiceImplClass = ConstVal.SUPERD_SERVICEIMPL_CLASS;
+            superServiceImplClass = ConstVal.SUPER_SERVICE_IMPL_CLASS;
         } else {
             superServiceImplClass = config.getSuperServiceImplClass();
         }
         if (StringUtils.isEmpty(config.getSuperMapperClass())) {
-            superMapperClass = ConstVal.SUPERD_MAPPER_CLASS;
+            superMapperClass = ConstVal.SUPER_MAPPER_CLASS;
         } else {
             superMapperClass = config.getSuperMapperClass();
         }
@@ -362,7 +370,7 @@ public class ConfigBuilder {
             if (StringUtils.isNotEmpty(globalConfig.getServiceImplName())) {
                 tableInfo.setServiceImplName(String.format(globalConfig.getServiceImplName(), tableInfo.getEntityName()));
             } else {
-                tableInfo.setServiceImplName(tableInfo.getEntityName() + ConstVal.SERVICEIMPL);
+                tableInfo.setServiceImplName(tableInfo.getEntityName() + ConstVal.SERVICE_IMPL);
             }
             if (StringUtils.isNotEmpty(globalConfig.getControllerName())) {
                 tableInfo.setControllerName(String.format(globalConfig.getControllerName(), tableInfo.getEntityName()));
@@ -521,7 +529,7 @@ public class ConfigBuilder {
             /**
              * 性能优化,只处理需执行表字段 github issues/219
              */
-            includeTableList.forEach(ti -> this.convertTableFields(ti, config.getColumnNaming()));
+            includeTableList.forEach(ti -> convertTableFields(ti, config.getColumnNaming()));
         } catch (SQLException e) {
             e.printStackTrace();
         } finally {
@@ -604,7 +612,7 @@ public class ConfigBuilder {
                     continue;
                 }
                 // 填充逻辑判断
-                List<TableFill> tableFillList = this.getStrategyConfig().getTableFillList();
+                List<TableFill> tableFillList = getStrategyConfig().getTableFillList();
                 if (null != tableFillList) {
                     tableFillList.stream().filter(tf -> tf.getFieldName().equals(field.getName()))
                         .findFirst().ifPresent(tf -> field.setFill(tf.getFieldFill().name()));
@@ -666,7 +674,7 @@ public class ConfigBuilder {
      * @return 根据策略返回处理后的名称
      */
     private String processName(String name, NamingStrategy strategy) {
-        return processName(name, strategy, this.strategyConfig.getFieldPrefix());
+        return processName(name, strategy, strategyConfig.getFieldPrefix());
     }
 
 

+ 42 - 40
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java

@@ -72,21 +72,21 @@ public abstract class AbstractTemplateEngine {
      */
     public AbstractTemplateEngine batchOutput() {
         try {
-            List<TableInfo> tableInfoList = this.getConfigBuilder().getTableInfoList();
+            List<TableInfo> tableInfoList = getConfigBuilder().getTableInfoList();
             for (TableInfo tableInfo : tableInfoList) {
-                Map<String, Object> objectMap = this.getObjectMap(tableInfo);
-                Map<String, String> pathInfo = this.getConfigBuilder().getPathInfo();
-                TemplateConfig template = this.getConfigBuilder().getTemplate();
+                Map<String, Object> objectMap = getObjectMap(tableInfo);
+                Map<String, String> pathInfo = getConfigBuilder().getPathInfo();
+                TemplateConfig template = getConfigBuilder().getTemplate();
                 // 自定义内容
-                InjectionConfig injectionConfig = this.getConfigBuilder().getInjectionConfig();
+                InjectionConfig injectionConfig = getConfigBuilder().getInjectionConfig();
                 if (null != injectionConfig) {
                     injectionConfig.initMap();
                     objectMap.put("cfg", injectionConfig.getMap());
                     List<FileOutConfig> focList = injectionConfig.getFileOutConfigList();
                     if (CollectionUtils.isNotEmpty(focList)) {
                         for (FileOutConfig foc : focList) {
-                            if (this.isCreate(foc.outputFile(tableInfo))) {
-                                this.writer(objectMap, foc.getTemplatePath(), foc.outputFile(tableInfo));
+                            if (isCreate(foc.outputFile(tableInfo))) {
+                                writer(objectMap, foc.getTemplatePath(), foc.outputFile(tableInfo));
                             }
                         }
                     }
@@ -94,44 +94,44 @@ public abstract class AbstractTemplateEngine {
                 // Mp.java
                 String entityName = tableInfo.getEntityName();
                 if (null != entityName && null != pathInfo.get(ConstVal.ENTITY_PATH)) {
-                    String entityFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + this.suffixJavaOrKt()), entityName);
-                    if (this.isCreate(entityFile)) {
-                        this.writer(objectMap, this.templateFilePath(template.getEntity(this.getConfigBuilder().getGlobalConfig().isKotlin())), entityFile);
+                    String entityFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + suffixJavaOrKt()), entityName);
+                    if (isCreate(entityFile)) {
+                        writer(objectMap, templateFilePath(template.getEntity(getConfigBuilder().getGlobalConfig().isKotlin())), entityFile);
                     }
                 }
                 // MpMapper.java
                 if (null != tableInfo.getMapperName() && null != pathInfo.get(ConstVal.MAPPER_PATH)) {
-                    String mapperFile = String.format((pathInfo.get(ConstVal.MAPPER_PATH) + File.separator + tableInfo.getMapperName() + this.suffixJavaOrKt()), entityName);
-                    if (this.isCreate(mapperFile)) {
-                        this.writer(objectMap, this.templateFilePath(template.getMapper()), mapperFile);
+                    String mapperFile = String.format((pathInfo.get(ConstVal.MAPPER_PATH) + File.separator + tableInfo.getMapperName() + suffixJavaOrKt()), entityName);
+                    if (isCreate(mapperFile)) {
+                        writer(objectMap, templateFilePath(template.getMapper()), mapperFile);
                     }
                 }
                 // MpMapper.xml
                 if (null != tableInfo.getXmlName() && null != pathInfo.get(ConstVal.XML_PATH)) {
                     String xmlFile = String.format((pathInfo.get(ConstVal.XML_PATH) + File.separator + tableInfo.getXmlName() + ConstVal.XML_SUFFIX), entityName);
-                    if (this.isCreate(xmlFile)) {
-                        this.writer(objectMap, this.templateFilePath(template.getXml()), xmlFile);
+                    if (isCreate(xmlFile)) {
+                        writer(objectMap, templateFilePath(template.getXml()), xmlFile);
                     }
                 }
                 // IMpService.java
                 if (null != tableInfo.getServiceName() && null != pathInfo.get(ConstVal.SERVICE_PATH)) {
-                    String serviceFile = String.format((pathInfo.get(ConstVal.SERVICE_PATH) + File.separator + tableInfo.getServiceName() + this.suffixJavaOrKt()), entityName);
-                    if (this.isCreate(serviceFile)) {
-                        this.writer(objectMap, this.templateFilePath(template.getService()), serviceFile);
+                    String serviceFile = String.format((pathInfo.get(ConstVal.SERVICE_PATH) + File.separator + tableInfo.getServiceName() + suffixJavaOrKt()), entityName);
+                    if (isCreate(serviceFile)) {
+                        writer(objectMap, templateFilePath(template.getService()), serviceFile);
                     }
                 }
                 // MpServiceImpl.java
-                if (null != tableInfo.getServiceImplName() && null != pathInfo.get(ConstVal.SERVICEIMPL_PATH)) {
-                    String implFile = String.format((pathInfo.get(ConstVal.SERVICEIMPL_PATH) + File.separator + tableInfo.getServiceImplName() + this.suffixJavaOrKt()), entityName);
-                    if (this.isCreate(implFile)) {
-                        this.writer(objectMap, this.templateFilePath(template.getServiceImpl()), implFile);
+                if (null != tableInfo.getServiceImplName() && null != pathInfo.get(ConstVal.SERVICE_IMPL_PATH)) {
+                    String implFile = String.format((pathInfo.get(ConstVal.SERVICE_IMPL_PATH) + File.separator + tableInfo.getServiceImplName() + suffixJavaOrKt()), entityName);
+                    if (isCreate(implFile)) {
+                        writer(objectMap, templateFilePath(template.getServiceImpl()), implFile);
                     }
                 }
                 // MpController.java
                 if (null != tableInfo.getControllerName() && null != pathInfo.get(ConstVal.CONTROLLER_PATH)) {
-                    String controllerFile = String.format((pathInfo.get(ConstVal.CONTROLLER_PATH) + File.separator + tableInfo.getControllerName() + this.suffixJavaOrKt()), entityName);
-                    if (this.isCreate(controllerFile)) {
-                        this.writer(objectMap, this.templateFilePath(template.getController()), controllerFile);
+                    String controllerFile = String.format((pathInfo.get(ConstVal.CONTROLLER_PATH) + File.separator + tableInfo.getControllerName() + suffixJavaOrKt()), entityName);
+                    if (isCreate(controllerFile)) {
+                        writer(objectMap, templateFilePath(template.getController()), controllerFile);
                     }
                 }
             }
@@ -159,7 +159,7 @@ public abstract class AbstractTemplateEngine {
      * </p>
      */
     public AbstractTemplateEngine mkdirs() {
-        this.getConfigBuilder().getPathInfo().forEach((key, value) -> {
+        getConfigBuilder().getPathInfo().forEach((key, value) -> {
             File dir = new File(value);
             if (!dir.exists()) {
                 boolean result = dir.mkdirs();
@@ -178,16 +178,18 @@ public abstract class AbstractTemplateEngine {
      * </p>
      */
     public void open() {
-        if (this.getConfigBuilder().getGlobalConfig().isOpen()) {
+        String outDir = getConfigBuilder().getGlobalConfig().getOutputDir();
+        if (getConfigBuilder().getGlobalConfig().isOpen()
+            && StringUtils.isNotEmpty(outDir)) {
             try {
                 String osName = System.getProperty("os.name");
                 if (osName != null) {
                     if (osName.contains("Mac")) {
-                        Runtime.getRuntime().exec("open " + this.getConfigBuilder().getGlobalConfig().getOutputDir());
+                        Runtime.getRuntime().exec("open " + outDir);
                     } else if (osName.contains("Windows")) {
-                        Runtime.getRuntime().exec("cmd /c start " + this.getConfigBuilder().getGlobalConfig().getOutputDir());
+                        Runtime.getRuntime().exec("cmd /c start " + outDir);
                     } else {
-                        logger.debug("文件输出目录:" + this.getConfigBuilder().getGlobalConfig().getOutputDir());
+                        logger.debug("文件输出目录:" + outDir);
                     }
                 }
             } catch (IOException e) {
@@ -206,8 +208,8 @@ public abstract class AbstractTemplateEngine {
      * @return
      */
     public Map<String, Object> getObjectMap(TableInfo tableInfo) {
-        Map<String, Object> objectMap = new HashMap<>();
-        ConfigBuilder config = this.getConfigBuilder();
+        Map<String, Object> objectMap = new HashMap<>(30);
+        ConfigBuilder config = getConfigBuilder();
         if (config.getStrategyConfig().isControllerMappingHyphenStyle()) {
             objectMap.put("controllerMappingHyphenStyle", config.getStrategyConfig().isControllerMappingHyphenStyle());
             objectMap.put("controllerMappingHyphen", StringUtils.camelToHyphen(tableInfo.getEntityPath()));
@@ -231,15 +233,15 @@ public abstract class AbstractTemplateEngine {
         objectMap.put("entityBuilderModel", config.getStrategyConfig().isEntityBuilderModel());
         objectMap.put("entityLombokModel", config.getStrategyConfig().isEntityLombokModel());
         objectMap.put("entityBooleanColumnRemoveIsPrefix", config.getStrategyConfig().isEntityBooleanColumnRemoveIsPrefix());
-        objectMap.put("superEntityClass", this.getSuperClassName(config.getSuperEntityClass()));
+        objectMap.put("superEntityClass", getSuperClassName(config.getSuperEntityClass()));
         objectMap.put("superMapperClassPackage", config.getSuperMapperClass());
-        objectMap.put("superMapperClass", this.getSuperClassName(config.getSuperMapperClass()));
+        objectMap.put("superMapperClass", getSuperClassName(config.getSuperMapperClass()));
         objectMap.put("superServiceClassPackage", config.getSuperServiceClass());
-        objectMap.put("superServiceClass", this.getSuperClassName(config.getSuperServiceClass()));
+        objectMap.put("superServiceClass", getSuperClassName(config.getSuperServiceClass()));
         objectMap.put("superServiceImplClassPackage", config.getSuperServiceImplClass());
-        objectMap.put("superServiceImplClass", this.getSuperClassName(config.getSuperServiceImplClass()));
+        objectMap.put("superServiceImplClass", getSuperClassName(config.getSuperServiceImplClass()));
         objectMap.put("superControllerClassPackage", config.getSuperControllerClass());
-        objectMap.put("superControllerClass", this.getSuperClassName(config.getSuperControllerClass()));
+        objectMap.put("superControllerClass", getSuperClassName(config.getSuperControllerClass()));
         return objectMap;
     }
 
@@ -278,9 +280,9 @@ public abstract class AbstractTemplateEngine {
         File file = new File(filePath);
         boolean exist = file.exists();
         if (!exist) {
-            this.mkDir(file.getParentFile());
+            mkDir(file.getParentFile());
         }
-        return !exist || this.getConfigBuilder().getGlobalConfig().isFileOverride();
+        return !exist || getConfigBuilder().getGlobalConfig().isFileOverride();
     }
 
     protected void mkDir(File file) {
@@ -296,7 +298,7 @@ public abstract class AbstractTemplateEngine {
      * 文件后缀
      */
     protected String suffixJavaOrKt() {
-        return this.getConfigBuilder().getGlobalConfig().isKotlin() ? ConstVal.KT_SUFFIX : ConstVal.JAVA_SUFFIX;
+        return getConfigBuilder().getGlobalConfig().isKotlin() ? ConstVal.KT_SUFFIX : ConstVal.JAVA_SUFFIX;
     }
 
 

+ 1 - 1
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/VelocityTemplateEngine.java

@@ -48,7 +48,7 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
         super.init(configBuilder);
         if (null == velocityEngine) {
             Properties p = new Properties();
-            p.setProperty(ConstVal.VM_LOADPATH_KEY, ConstVal.VM_LOADPATH_VALUE);
+            p.setProperty(ConstVal.VM_LOAD_PATH_KEY, ConstVal.VM_LOAD_PATH_VALUE);
             p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "");
             p.setProperty(Velocity.ENCODING_DEFAULT, ConstVal.UTF8);
             p.setProperty(Velocity.INPUT_ENCODING, ConstVal.UTF8);