码迷,mamicode.com
首页 > 编程语言 > 详细

告别永无止境的CRUD, 从零开始写Java代码生成器(一)

时间:2016-06-25 13:46:25      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:

近总是不断的在增删改查,复制, 粘贴, 有什么办法能摆脱这种现状呢? 我知道你也一定很讨厌重复的工作, 庞大的管理系统让我们把复制粘贴运用到了极致,这样永无止境下去, 跟搬砖又有什么区别?

于是, 动手来写一个代码生成器吧! 从Javabean到Dao,Mapper,Service,Controller,JSP 都交给代码生成器来完成好不好?

 

新建一个Maven项目,CodeGenerator, 其pom.xml核心配置如下:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <groupId>cn.org.j2ee</groupId>
 5     <artifactId>CodeGenerator</artifactId>
 6     <version>0.0.1-SNAPSHOT</version>
 7     <packaging>jar</packaging>
 8     <name>CodeGenerator</name>
 9     <url>http://www.j2ee.org.cn</url>
10     <description>Java代码生成器</description>
11 
12     <properties>
13         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14     </properties>
15 
16     <dependencies>
17         <dependency>
18             <groupId>junit</groupId>
19             <artifactId>junit</artifactId>
20             <version>4.10</version>
21             <scope>test</scope>
22         </dependency>
23         <dependency>
24             <groupId>commons-collections</groupId>
25             <artifactId>commons-collections</artifactId>
26             <version>3.1</version>
27         </dependency>
28         <dependency>
29             <groupId>commons-lang</groupId>
30             <artifactId>commons-lang</artifactId>
31             <version>2.4</version>
32         </dependency>
33         <dependency>
34             <groupId>commons-logging</groupId>
35             <artifactId>commons-logging</artifactId>
36             <version>1.1.1</version>
37         </dependency>
38         <dependency>
39             <groupId>dom4j</groupId>
40             <artifactId>dom4j</artifactId>
41             <version>1.6</version>
42         </dependency>
43         <dependency>
44             <groupId>log4j</groupId>
45             <artifactId>log4j</artifactId>
46             <version>1.2.16</version>
47         </dependency>
48         <dependency>
49             <groupId>org.apache.velocity</groupId>
50             <artifactId>velocity</artifactId>
51             <version>1.7</version>
52         </dependency>
53         <dependency>
54             <groupId>mysql</groupId>
55             <artifactId>mysql-connector-java</artifactId>
56             <version>5.1.26</version>
57         </dependency>
58         <!-- Servlet -->
59         <dependency>
60             <groupId>javax.servlet</groupId>
61             <artifactId>servlet-api</artifactId>
62             <version>2.5</version>
63             <scope>provided</scope>
64         </dependency>
65         <dependency>
66             <groupId>javax.servlet.jsp</groupId>
67             <artifactId>jsp-api</artifactId>
68             <version>2.1</version>
69             <scope>provided</scope>
70         </dependency>
71         <dependency>
72             <groupId>javax.servlet</groupId>
73             <artifactId>jstl</artifactId>
74             <version>1.2</version>
75         </dependency>
76         <dependency>
77             <groupId>dom4j</groupId>
78             <artifactId>dom4j</artifactId>
79             <version>1.6.1</version>
80         </dependency>
81     </dependencies>
82 </project>

 pom.xml 中加入了一些可能或者必须用到的jar包;

 

整体的项目结构大致如下:(目前版本0.1)

技术分享

 

待续...

 

告别永无止境的CRUD, 从零开始写Java代码生成器(一)

标签:

原文地址:http://www.cnblogs.com/winzel/p/5616207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!