It would be nice if you could make a lot of coding work easier in your project.
After velocity, I suddenly had the idea of using velocity, the excellent template engine, to make repetitive code in development projects automatically generated
After the generation of the basic code, in accordance with the actual needs of a slight modification can be run, greatly improve the efficiency.
So I wrote this code generation tool (the template engine generated by the code is partly extended on the basis of a previous colleague's code)
The second edition, which reads the tables of the specified data types and databases, generates three-tier code for each table according to the module
Includes: Bean,controller,service,serviceimpl,dao,daoimpl
Shortcomings and deficiencies in the template file with a high degree of coupling, module files can only be on the template I provide a small number of changes
Before the first edition, it was the JavaBean to read the bean in a project, the code that generated the three-tier structure of each bean according to the module
and JavaBean to use tools such as myeclipse to export javabean from the database or write manually JavaBean
Usage considerations:
1. Prepare database and JDBC driver package
2. Tables used in the database for the construction of the project
3. You can only use the sample template file I provided (a file with a VM extension) for a few changes
Gavin (Zhang Yixuan) QQ 106128696
Part of the code is as follows List < String > list = tablenames;
if (list = = NULL | | List.size () = = 0) ... {
throw new Exception ("Cannot create JavaBean");
}
Completestatus = false;
int listsize = List.size ();
Totalfilecount = Listsize * Tasklist.size ();
int tasksize = Tasklist.size ();
Beanutil beanutil = new Beanutil ();
for (int k = 0; k < tasksize;k + +) ... {
if (Threadstatus.equals (threadstatus.stop))
Break
while (Threadstatus.equals (threadstatus.pause)) ... {
Thread.Sleep (100);
}
String directoryname = "";
String fileName = "";
DirectoryName = Splitdirectory (Tasklist.get (k) [1], false);
for (int i = 0; i < listsize i++) ... {
if (Threadstatus.equals (threadstatus.stop))
Break
while (Threadstatus.equals (threadstatus.pause)) ... {
Thread.Sleep (100);
}
String beanfilename = List.get (i);
Velocitycontext context = new Velocitycontext ();
Context.put ("name", Beanfilename);
Context.put ("PackageName", Tasklist.get (k) [1]);
Create Bean
if (k==0) ... {
list<fieldinfo> beanfieldlist = Beanutil.getbeaninfo (beanfilename);
Context.put ("Beanfieldlist", beanfieldlist);
}else ... {
String lowercasefilename = beanfilename.substring (0, 1)
. toLowerCase ()
+ beanfilename.substring (1);
Context.put ("parameter", lowercasefilename);
Context.put ("Modename", modename);
Context.put ("pack", bean);
}
Template Template = null;
Template = Velocity.gettemplate (Tasklist.get (k) [0]);
FileName = directoryname + file.separator + beanfilename + tasklist.get (k) [2]
+ ". Java";
File Directoryfile = new file (directoryname);
This.out (Outpanel, "Create File: ..." + filename
+ " ");