资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

设置java代码模板 java界面设计代码

eclipse怎么修改新建java文件时的默认模板?

方法如下:

专注于为中小企业提供成都网站制作、成都网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业海西免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了千余家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

依次点击eclipse菜单栏上的window(工具栏)-preference-java(左边菜单)-Code Style-Code Template-code(右边)-class body-edit(点击右边按钮)

输入void f()(弹出框中)-ok-ok

eclipse怎么设置创建一个java文件后自动加入注释

eclipse设置创建一个java文件后自动加入注释的方法:

1、通过菜单 Window-Preference 打开参数设置面板,然后选择:

Java - Code Style - Code  Templates

2、在右侧选择Comments,将其中的Files项,然后选右边的"Edit",进入编辑模式:   

3、进入编辑模式后就可以自定义注释了。另外可以插入一些变量,如年、日期等等。

4、最后,确保 Code - New Java files 中有:"${filecomment}"

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=”/createCode”)

public class CreateCodeController extends BaseController {

/**

* 生成代码

*/

@RequestMapping(value=”/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”);

}

}

如何在eclipse 中设置自动添加Javadoc注释

先看默认状态的吧,新建类文件时,是不生成注释的

windows--preferenceJava--Code Style--Code Templatescode--new Java file

编辑文件为7的样式,(为了方便起见,中间分布截图说明,熟悉的朋友直接跳到7)

对于中文版本

窗口--首选项

java--代码样式--代码模板

代码--新的java文件

菜单栏,窗口——首选项

找到java选项--代码样式

注释--新生成的java文件

直接编辑配置文件

在配置文件中间添加注释代码,这部分可以自定义,参考如下,关键字解释见后文10

------------------我是分割线,别复制我-----------------------------------

${filecomment}${package_declaration}/** * @author 作者 E-mail: * @date 创建时间:${date} ${time} * @version 1.0 * @parameter * @since * @return */${typecomment}${type_declaration}

------------------我是分割线,别复制我-----------------------------------

现在新建文件将自动生成注释

补充说明;

也许你看到我们在写注释文件时用到了很多关键字,那么这里我们就了解一下Javadoc

Javadoc是Sun公司提供的一个技术,它从程序源代码中抽取类、方法、成员等注释形成一个和源代码配套的API帮助文档。也就是说,只要在编写程序时以一套特定的标签作注释,在程序编写完成后,通过Javadoc就可以同时形成程序的开发文档了

关键词列表:

@author 作者名

@date 日期

@version 版本标识

@parameter 参数及其意义

@since 最早使用该方法/类/接口的JDK版本

@return 返回值

@throws 异常类及抛出条件

@deprecated 引起不推荐使用的警告

@see reference 查看引用

@override 重写

更多Javadoc用法可以访问:百度百科、官方文档。


名称栏目:设置java代码模板 java界面设计代码
当前URL:http://cdkjz.cn/article/dojsoii.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220