该项目为javaWEB项目通用代码生成器,根据数据库表和自定义代码模板生成相应的jsp,js,java文件,生成到指定路径下,javaweb项目开发利器;

项目开源地址:https://gitee.com/okrs.cn/CodeGenerator

代码生成器:
该项目为代码生成器 基于Apache Velocity的 Java模板引擎
base_build文件夹为最原始代码
为整理后的版本
执行:
com.mmk.BaseApplication.java或生成jar包:run Maven intall

访问路径:http://localhost:10001/codeUI/index.html

不可用ip 访问

登录界面输入的是作者

模板加载地址:

resources/static/template.json

添加模板地址:
src/main/resources/

com.mmk.code.common.PropertyNameTools.java 设置表初始加载的时候数据库字段类型对应的实体字段类型

#foreach($field in $fieldList)
 #if($!{velocityCount}==$!{fieldList.size()})//当循环到最后一个时
  " s.${field.columnName}"+
#else
  " s.${field.columnName},"+
#end 
   #end;
   
   $fieldList 字段列表
    ${field.comment} 字段描述
${field.columnName}数据库字段名称
${field.inputType} 数据库类型
${field.validate}
${field.field} 实体字段名称
${field.fieldUp} 实体字段名称大写
${field.type} 实体字段类型

$field.findBy) 启用特殊方法findBy

以上对应字段值设置
\resources\static\codeUI\app\store
${field.inputType}=="input"
#if($field.validate=="mobile")lay-verify="phone"#elseif(!$field.nullable)lay-verify="required"#end
#if( $field.type == "Date")

${model.packageName}.${model.modulePackage}
${model.model}大写 实体名字
${model.modelL}首字母小写 实体名字
${model.comment}

*@author ${model.author} ${date}

${model.tableName} 数据库名字

表单验证:
 <input type="text"  name="${field.field}" placeholder="请输入${field.comment}" autocomplete="off"  data-rule="${field.comment};required;#if(${field.validate})${field.validate};" data-msg="不符合规则" #else " #end value="${${model.modelL}.${field.field}}"/>

生成:
 <input type="text"  name="type" placeholder="请输入违规类型,0-一般,1-严重" autocomplete="off"  data-rule="违规类型,0-一般,1-严重;required;number;" data-msg="不符合规则"  value="${cbViolateNotice.type}"/>

sql拼接
#if($field.type=="String")
#if($field.matchType == 'any')
        sql.append(" and s.name like '%").append(search_name).append("%'");
#elseif($field.matchType == 'eq')
        if(StringUtils.isNotBlank(condition.get${field.fieldUp}())){
            sb.append(" and ${field.columnName} = ?$!{velocityCount} ");
            params.put($!{velocityCount},condition.get${field.fieldUp}());
        }
#elseif($field.matchType == 'left')
        if(StringUtils.isNotBlank(condition.get${field.fieldUp}())){
            sb.append(" and ${field.columnName} like ?$!{velocityCount} ");
            params.put($!{velocityCount},condition.get${field.fieldUp}()+"%");
        }
#elseif($field.matchType == 'right')
        if(StringUtils.isNotBlank(condition.get${field.fieldUp}())){
            sb.append(" and ${field.columnName} like ?$!{velocityCount} ");
            params.put($!{velocityCount},"%"+condition.get${field.fieldUp}());
        }
#elseif($field.matchType == 'dateRange')
        if(condition.get${field.fieldUp}Begin()!=null){
            sb.append(" and ${field.columnName} >= ?$!{velocityCount} ");
            params.put($!{velocityCount},condition.get${field.fieldUp}Begin());
        }
        if(condition.get${field.fieldUp}End()!=null){
            sb.append(" and ${field.columnName} >= ?$!{velocityCount} ");
            params.put($!{velocityCount},condition.get${field.fieldUp}End());
        }
#end
#else
#if($field.matchType != 'none')
        if(condition.get${field.fieldUp}()!=null){
            sb.append(" and ${field.columnName} = ?$!{velocityCount} ");
            params.put($!{velocityCount},condition.get${field.fieldUp}());
        }
#end
#end

模拟文件结构不能更改,删除其中的文件会报错

注意:
1、生成代码的时候会直接覆盖
2、maven 生成的jar包 会存在乱码问题:解决方式:命令行中执行  java -Dfile.encoding=utf-8 -jar APA_BUILD-1.0.0.jar

-------------------------------------------------------------------

1、生成代码的时候会直接覆盖
2、必须设计表的时候
字段填写注释
表上填写注释
3、数据库中设计必须有:id(自增),code(uuid,标识),create_time,create_code,update_code,update_time,del_flag(逻辑删除,1)

-------------------------------------------------------------

最新文章

  1. 使用python处理子域名爆破工具subdomainsbrute结果txt
  2. Unable to download data from http://ruby.taobao.org/ &amp; don&#39;t have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
  3. Javascript学习笔记:3种定义函数的方式
  4. createElement() 创建元素 appendChild()添加元素
  5. Haproxy安装与配置
  6. objective-c 一个链式加法计算器实现
  7. Myeclipse安装svn插件(link方式)
  8. iOS - 操作文件目录的方法
  9. http://www.cnblogs.com/xdp-gacl/p/3622275.html
  10. 场景类(CCSence)
  11. dispatch队列
  12. Ruby的语法糖
  13. android apk打包之后js调用失效的解决办法
  14. 【单源最短路模板】 poj 2387
  15. SSH连接GitHub并配置ssh key
  16. Openvswitch手册(4): Mirror
  17. 1、python环境安装及软件介绍
  18. C#基础巩固(2)-Linq To XML创建XML
  19. ios 懒加载详解
  20. STL之容器(containers) 简介

热门文章

  1. Android -传统蓝牙通信聊天
  2. wss 协议传送过来的数据是经过 gzip 压缩过的,如何使用 qt 解压该数据呢?
  3. UVa 11988破损的键盘
  4. ReportView动态加载带参数的RDCL文件
  5. Spring注解简介
  6. gitlab启用https
  7. 关于服务器的CPU的几个概念学习总结
  8. ubuntu11.04编译gm8180的ffmpeg
  9. Android常见漏洞
  10. 字符串压缩 stringZip