最近总是不断的在增删改查,复制, 粘贴, 有什么办法能摆脱这种现状呢? 我知道你也一定很讨厌重复的工作, 庞大的管理系统让我们把复制粘贴运用到了极致,这样永无止境下去, 跟搬砖又有什么区别?
于是, 动手来写一个代码生成器吧! 从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)
待续...
时间: 2024-12-31 14:27:47