java手写代码生成器 java代码生成器推荐

代码生成器是干什么用的,谁用过代码生成器是按照特定编码规范输出代码java手写代码生成器的软件,可以直接生成项目,也可以单页生成
比如动软,生成项目可以选择vs版本的 , 其实嘛,动软挺垃圾的 , 不如java手写代码生成器你去学学orm框架 , 很简单的,比动软的三层好得多
java代码生成器怎么用zip包 , 然后自动下载下来
1.预先定义好模板
2.界面输入相关参数
3.解析模板生成代码并下载
最后放出源代码:
package com.et.controller.system.createcode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.et.controller.base.BaseController;
import com.et.util.DelAllFile;
import com.et.util.FileDownload;
import com.et.util.FileZip;
import com.et.util.Freemarker;
import com.et.util.PageData;
import com.et.util.PathUtil;
/**
* 类名称:FreemarkerController
* 创建人:Harries
* 创建时间:2015年1月12日
* @version
*/
@Controller
@RequestMapping(value=https://www.04ip.com/post/”/createCode”)
public class CreateCodeController extends BaseController {
/**
* 生成代码
*/
@RequestMapping(value=https://www.04ip.com/post/”/proCode”)
public void proCode(HttpServletResponse response) throws Exception{
PageData pd = new PageData();
pd = this.getPageData();
/* ============================================================================================= */
String packageName = pd.getString(“packageName”); //包名 ========1
String objectName = pd.getString(“objectName”); //类名 ========2
String tabletop = pd.getString(“tabletop”); //表前缀 ========3
tabletop = null == tabletop?””:tabletop.toUpperCase(); //表前缀转大写
String zindext = pd.getString(“zindex”); //属性总数
int zindex = 0;
if(null != zindext!””.equals(zindext)){
zindex = Integer.parseInt(zindext);
}
ListString[] fieldList = new ArrayListString[](); //属性集合 ========4
for(int i=0; i zindex; i){
fieldList.add(pd.getString(“field” i).split(“,fh,”)); //属性放到集合里面
}
MapString,Object root = new HashMapString,Object(); //创建数据模型
root.put(“fieldList”, fieldList);
root.put(“packageName”, packageName); //包名
root.put(“objectName”, objectName); //类名
root.put(“objectNameLower”, objectName.toLowerCase()); //类名(全小写)
root.put(“objectNameUpper”, objectName.toUpperCase()); //类名(全大写)
root.put(“tabletop”, tabletop); //表前缀
root.put(“nowDate”, new Date()); //当前日期
DelAllFile.delFolder(PathUtil.getClasspath() ”admin/ftl”); //生成代码前,先清空之前生成的代码
/* ============================================================================================= */
String filePath = “admin/ftl/code/”; //存放路径
String ftlPath = “createCode”; //ftl路径
/*生成controller*/
Freemarker.printFile(“controllerTemplate.ftl”, root, “controller/” packageName ”/” objectName.toLowerCase() ”/” objectName ”Controller.java”, filePath, ftlPath);
/*生成service*/
Freemarker.printFile(“serviceTemplate.ftl”, root, “service/” packageName ”/” objectName.toLowerCase() ”/” objectName ”Service.java”, filePath, ftlPath);
/*生成mybatis xml*/
Freemarker.printFile(“mapperMysqlTemplate.ftl”, root, “mybatis_mysql/” packageName ”/” objectName ”Mapper.xml”, filePath, ftlPath);
Freemarker.printFile(“mapperOracleTemplate.ftl”, root, “mybatis_oracle/” packageName ”/” objectName ”Mapper.xml”, filePath, ftlPath);
/*生成SQL脚本*/
Freemarker.printFile(“mysql_SQL_Template.ftl”, root, “mysql数据库脚本/” tabletop objectName.toUpperCase() ”.sql”, filePath, ftlPath);
Freemarker.printFile(“oracle_SQL_Template.ftl”, root, “oracle数据库脚本/” tabletop objectName.toUpperCase() ”.sql”, filePath, ftlPath);
/*生成jsp页面*/
Freemarker.printFile(“jsp_list_Template.ftl”, root, “jsp/” packageName ”/” objectName.toLowerCase() ”/” objectName.toLowerCase() ”_list.jsp”, filePath, ftlPath);
Freemarker.printFile(“jsp_edit_Template.ftl”, root, “jsp/” packageName ”/” objectName.toLowerCase() ”/” objectName.toLowerCase() ”_edit.jsp”, filePath, ftlPath);
/*生成说明文档*/
Freemarker.printFile(“docTemplate.ftl”, root, “说明.doc”, filePath, ftlPath);
//this.print(“oracle_SQL_Template.ftl”, root); 控制台打印
/*生成的全部代码压缩成zip文件*/
FileZip.zip(PathUtil.getClasspath() ”admin/ftl/code”, PathUtil.getClasspath() ”admin/ftl/code.zip”);
/*下载代码*/
FileDownload.fileDownload(response, PathUtil.getClasspath() ”admin/ftl/code.zip”, “code.zip”);
}
}
java代码生成器能生成c语言代码吗?用什么方法能实现呢?按照我的理解,可以的,代码生成器是跨平台,而且是跨语言的(至少是跨文本语言的,UML暂时不好说,) 。
代码生成器作为一种开发工具,一般不直接作为程序的一部分,通常也不直接或间接(如通过AOP)被程序调用 , 他是通过编程的方式生成所需要的代码,然后将生成的代码作为源文件 , 复制到开发工具的代码区,然后进行编译 。由于代码生成器是在编译之前运行的,因此它可以跨语言,你不但可以用代码生成器生成高级语言,也可以生成汇编语言,甚至机器码(0、1代码) 。
但编写代码生成器是一个难点,它需要你了解目标编程语言的语法 。如果别人已经把你需要的代码生成器写好了 , 你只需按要求使用即可,此时就不需要了解目标编程语言的语法 。
JNI是通过Java调用C语言(或其他语言,一般是C),它的实现机制与代码生成器不同(JNI是通过代码调用实现功能,而代码生成器是生成代码 , 复制代码进行使用),由于C是底层语言 , 一些底层操作单靠Java无法实现,所以才需要JNI 。
以上是我对代码生成器的个人理解,虽然提问时间已过了很久,但依然希望能对你及其他网友有所帮助 。
java代码生成器用途代码生成器就是根据特定的要求制定格式java手写代码生成器,灵活输出在项目中重复要用到的代码 , 节省项目时间,现在免费的代码生成器codesmithjava手写代码生成器我经常用的,小玩意 , 不花钱
【java手写代码生成器 java代码生成器推荐】关于java手写代码生成器和java代码生成器推荐的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读