资讯

精准传达 • 有效沟通

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

自动生成生成java代码 java代码自动生成开发工具

Myeclipse中如何自动生成Java代码啊

myeclipse没有直接的快捷键自动生成构造方法,可以有快捷键弹出source,接着点击自动生成构造方法的菜单。

成都创新互联-专业网站定制、快速模板网站建设、高性价比临澧网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式临澧网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖临澧地区。费用合理售后完善,10年实体公司更值得信赖。

具体操作如下:工具里快捷键alt+shift+s

就弹出来Generate

Constructor

using

Fields

怎样利用 eclipse mybatis generator 自动生成代码

MyBatis中,可以使用Generator自动生成代码,包括DAO层、 MODEL层 、MAPPING SQL映射文件。

第一步:下载MyBatis的Generator工具

htt p:/ /mybati s.gith ub.i o/generator/

第二步:配置自动生成代码所需的XML配置文件,例如(generator.xml)

将这个文件保存至你下载的mybatis-generator-core-1.3.2文件夹下

第三步:进入XML配置文件(generator.xml)所在的的目录并执行命令:

Dos代码

java -jar E:\mybatis-generator-core-1.3.2\lib\mybatis-generator-core-1.3.2.j ar -configfile generator.xml -overwrite

mybatis generator eclipse插件的安装

打开eclipse,点击HelpSoftware Update

选择 "Available Software" 标签,点击 "Add Site" 按钮

输入以下信息:

Location:htt p:/ /mybatis.googleco de.c om/svn/sub-projects/gen erator/trunk/eclipse/UpdateSite/

点击ok,自动进入"mybatis generator Feature"

点击“install”按钮进行安装。。。。mybatis generator 插件安装完成

配置Mybatis Generator不要生成Example类

Mybatis Generator默认设置会生成一大堆罗哩罗嗦的Example类,主要是用各种不同的条件来操作数据库,大部分是用不到的,用到的时候手工修改mapper和接口文件就行了。

/codetable

schema="general"

tableName="tb_table_name"

domainObjectName="EntityName"

enableCountByExample="false"

enableUpdateByExample="false"

enableDeleteByExample="false"

enableSelectByExample="false"

selectByExampleQueryId="false"

name="useActualColumnNames"

value="true"/

//codetable

这样生成的mapper和dao接口就清爽多了。

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”);

}

}

如何在cxf3版本自动生成的java代码中增加he

1、选择新建的工程后,点击右键,选择“Run As”-“Run”,如下图所示:

2、弹出如下窗口:

3、 在上图中,左边选择“Java Application”后,点击左上角的新增“”按钮new configuration,页面如下图所示:

4、在上图中,将“Include libraries when searching for a main class” 勾上,而后点击“Main class”右边的“Search”按钮,弹出窗口如下图所示:

5、在上图中输入WSDL2Java后,查找到axis这个jar包中对应类,点击“OK”按钮,此时主窗口如下图所示:

6、在上图中点击“Arguments”页签,Arguments里把要生成的web service URI或wsdl文件写进去,最后点run。在下图中输入的是wsdl文件的路径:     src/wsdl/acd_accessCode_interface.wsdl、src/wsdl/acd_accessCode_service.wsdl:

7、生成的java代码如下:

自己编写根据数据库自动生成java代码思路?

是为了生成对应的bean吗?

好几年前做过类似的,也看过其他类似产品的代码,基本思路就是遍历呗。

先通过sql检索所有的表或view,然后针对每个表遍历字段,再给字段类型定义个匹配关系。然后一行行出代码就行了。。想做的好点,就做个图形界面,然后把一些选择的条件(比如package,加不加注解等等)通过图形界面登录,就行了。

有没有uml工具能自动生成java代码的?

常用的是StarUML,其他一些UML软件,如Rational Rose都是可以的,即可正向生成,也可以逆向生成


网页标题:自动生成生成java代码 java代码自动生成开发工具
网站URL:http://cdkjz.cn/article/dodpegi.html
多年建站经验

多一份参考,总有益处

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

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

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220