这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
分享:技术:示例项目:springmvc_mybatis_spring_freemarker_maven [2015/07/07 08:31] gxx |
分享:技术:示例项目:springmvc_mybatis_spring_freemarker_maven [2015/07/07 10:37] (当前版本) gxx |
||
---|---|---|---|
行 8: | 行 8: | ||
| maven | 3.0 | | | maven | 3.0 | | ||
===== 项目结构 ===== | ===== 项目结构 ===== | ||
- | {{ :分享:技术:模板项目:项目结构.png?300 |}} | + | {{ :分享:技术:示例项目:项目结构.png?300 |}} |
===== 源代码 ===== | ===== 源代码 ===== | ||
+ | ==== UserMapper.java ==== | ||
<file java UserMapper.java> | <file java UserMapper.java> | ||
package com.gxx.record.base.dao; | package com.gxx.record.base.dao; | ||
行 39: | 行 40: | ||
} | } | ||
</file> | </file> | ||
+ | ==== UserMapper.xml ==== | ||
<file xml UserMapper.xml> | <file xml UserMapper.xml> | ||
<?xml version="1.0" encoding="UTF-8" ?> | <?xml version="1.0" encoding="UTF-8" ?> | ||
行 141: | 行 143: | ||
</mapper> | </mapper> | ||
</file> | </file> | ||
+ | ==== User.java ==== | ||
<file java User.java> | <file java User.java> | ||
package com.gxx.record.base.vo; | package com.gxx.record.base.vo; | ||
行 196: | 行 199: | ||
} | } | ||
</file> | </file> | ||
+ | ==== BaseDto.java ==== | ||
<file java BaseDto.java> | <file java BaseDto.java> | ||
package com.gxx.record.dto; | package com.gxx.record.dto; | ||
行 235: | 行 239: | ||
} | } | ||
</file> | </file> | ||
+ | ==== UserDto.java ==== | ||
<file java UserDto.java> | <file java UserDto.java> | ||
package com.gxx.record.dto; | package com.gxx.record.dto; | ||
行 294: | 行 299: | ||
} | } | ||
</file> | </file> | ||
+ | ==== UserService.java ==== | ||
<file java UserService.java> | <file java UserService.java> | ||
package com.gxx.record.service; | package com.gxx.record.service; | ||
行 331: | 行 337: | ||
} | } | ||
</file> | </file> | ||
+ | ==== UserServiceImpl.java ==== | ||
<file java UserServiceImpl.java> | <file java UserServiceImpl.java> | ||
package com.gxx.record.service.impl; | package com.gxx.record.service.impl; | ||
行 382: | 行 389: | ||
} | } | ||
</file> | </file> | ||
+ | ==== UserController.java ==== | ||
<file java UserController.java> | <file java UserController.java> | ||
package com.gxx.record.web.user; | package com.gxx.record.web.user; | ||
行 495: | 行 503: | ||
} | } | ||
</file> | </file> | ||
+ | ==== application-context.xml ==== | ||
<file xml application-context.xml> | <file xml application-context.xml> | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
行 580: | 行 589: | ||
</beans> | </beans> | ||
</file> | </file> | ||
+ | ==== jdbc.properties ==== | ||
<file properties jdbc.properties> | <file properties jdbc.properties> | ||
jdbc.driverClassName=com.mysql.jdbc.Driver | jdbc.driverClassName=com.mysql.jdbc.Driver | ||
行 586: | 行 596: | ||
jdbc.password=root | jdbc.password=root | ||
</file> | </file> | ||
+ | ==== log4j.properties ==== | ||
<file properties log4j.properties> | <file properties log4j.properties> | ||
# Output pattern : date [thread] priority category - message FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 | # Output pattern : date [thread] priority category - message FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 | ||
行 601: | 行 612: | ||
log4j.appender.RollingFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n | log4j.appender.RollingFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n | ||
</file> | </file> | ||
+ | ==== mybatis.xml ==== | ||
<file xml mybatis.xml> | <file xml mybatis.xml> | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
行 615: | 行 627: | ||
</configuration> | </configuration> | ||
</file> | </file> | ||
+ | ==== spring-mvc.xml ==== | ||
<file xml spring-mvc.xml> | <file xml spring-mvc.xml> | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
行 722: | 行 735: | ||
</beans> | </beans> | ||
</file> | </file> | ||
+ | ==== MybatisGeneratorMain.java ==== | ||
<file java MybatisGeneratorMain.java> | <file java MybatisGeneratorMain.java> | ||
package com.gxx.record.generator; | package com.gxx.record.generator; | ||
行 793: | 行 807: | ||
} | } | ||
</file> | </file> | ||
+ | ==== generatorConfig.xml ==== | ||
<file xml generatorConfig.xml> | <file xml generatorConfig.xml> | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
行 850: | 行 865: | ||
</generatorConfiguration> | </generatorConfiguration> | ||
</file> | </file> | ||
- | <file xml generatorConfig.xml> | + | ==== preRegistFtl.ftl ==== |
+ | <file ftl preRegistFtl.ftl> | ||
+ | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
+ | <html xmlns="http://www.w3.org/1999/xhtml"> | ||
+ | <head> | ||
+ | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
+ | <title>注册页面</title> | ||
+ | </head> | ||
+ | <body> | ||
+ | <form action="/record/user/registFtl.htm" method="post"> | ||
+ | <table border="1"> | ||
+ | <tr><td>用户名:</td><td><input type="text" name="name"/></td></tr> | ||
+ | <tr><td>密码:</td><td><input type="password" name="password"/></td></tr> | ||
+ | <tr><td colspan="2" align="center"><input type="submit" value="提交"/></td></tr> | ||
+ | </table> | ||
+ | </form> | ||
+ | </body> | ||
+ | </html> | ||
</file> | </file> | ||
- | <file xml generatorConfig.xml> | + | ==== preRegistJsp.jsp ==== |
+ | <file jsp preRegistJsp.jsp> | ||
+ | <%@ page language="java" contentType="text/html; charset=UTF-8" | ||
+ | pageEncoding="UTF-8"%> | ||
+ | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
+ | <html xmlns="http://www.w3.org/1999/xhtml"> | ||
+ | <head> | ||
+ | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
+ | <title>注册页面</title> | ||
+ | </head> | ||
+ | <body> | ||
+ | <form action="/record/user/registJsp.htm" method="post"> | ||
+ | <table border="1"> | ||
+ | <tr><td>用户名:</td><td><input type="text" name="name"/></td></tr> | ||
+ | <tr><td>密码:</td><td><input type="password" name="password"/></td></tr> | ||
+ | <tr><td colspan="2" align="center"><input type="submit" value="提交"/></td></tr> | ||
+ | </table> | ||
+ | </form> | ||
+ | </body> | ||
+ | </html> | ||
</file> | </file> | ||
- | <file xml generatorConfig.xml> | + | ==== result.ftl ==== |
+ | <file ftl result.ftl> | ||
+ | <html> | ||
+ | <body> | ||
+ | <p>This is my result:<br> ${userDto.success?string('true','false')}</p> | ||
+ | <p>This is my message:<br> ${userDto.message}</p> | ||
+ | </body> | ||
+ | </html> | ||
</file> | </file> | ||
- | <file xml generatorConfig.xml> | + | ==== web.xml ==== |
+ | <file xml web.xml> | ||
+ | <!DOCTYPE web-app PUBLIC | ||
+ | "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | ||
+ | "http://java.sun.com/dtd/web-app_2_3.dtd" > | ||
+ | |||
+ | <web-app> | ||
+ | <display-name>Archetype Created Web Application</display-name> | ||
+ | |||
+ | <!-- Context Configuration locations for Spring XML files --> | ||
+ | <context-param> | ||
+ | <param-name>contextConfigLocation</param-name> | ||
+ | <param-value> | ||
+ | classpath*:/application-*.xml, | ||
+ | </param-value> | ||
+ | </context-param> | ||
+ | |||
+ | <filter> | ||
+ | <filter-name>encodingFilter</filter-name> | ||
+ | <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> | ||
+ | <init-param> | ||
+ | <param-name>encoding</param-name> | ||
+ | <param-value>UTF-8</param-value> | ||
+ | </init-param> | ||
+ | <init-param> | ||
+ | <param-name>forceEncoding</param-name> | ||
+ | <param-value>true</param-value> | ||
+ | </init-param> | ||
+ | </filter> | ||
+ | |||
+ | <filter-mapping> | ||
+ | <filter-name>encodingFilter</filter-name> | ||
+ | <url-pattern>/*</url-pattern> | ||
+ | </filter-mapping> | ||
+ | |||
+ | <!-- serlvet listeners --> | ||
+ | <listener> | ||
+ | <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
+ | </listener> | ||
+ | <listener> | ||
+ | <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> | ||
+ | </listener> | ||
+ | |||
+ | <servlet> | ||
+ | <servlet-name>dispatcher</servlet-name> | ||
+ | <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | ||
+ | <init-param> | ||
+ | <param-name>contextConfigLocation</param-name> | ||
+ | <param-value>classpath*:/spring-mvc.xml</param-value> | ||
+ | </init-param> | ||
+ | <load-on-startup>1</load-on-startup> | ||
+ | </servlet> | ||
+ | |||
+ | <servlet-mapping> | ||
+ | <servlet-name>dispatcher</servlet-name> | ||
+ | <url-pattern>*.htm</url-pattern> | ||
+ | </servlet-mapping> | ||
+ | |||
+ | <!-- welcome file list config --> | ||
+ | <welcome-file-list> | ||
+ | <welcome-file>index.jsp</welcome-file> | ||
+ | </welcome-file-list> | ||
+ | |||
+ | <jsp-config> | ||
+ | <jsp-property-group> | ||
+ | <display-name>JSPConfiguration</display-name> | ||
+ | <url-pattern>*.jsp</url-pattern> | ||
+ | <page-encoding>UTF-8</page-encoding> | ||
+ | </jsp-property-group> | ||
+ | </jsp-config> | ||
+ | </web-app> | ||
</file> | </file> | ||
- | <file xml generatorConfig.xml> | + | ==== index.jsp ==== |
+ | <file jsp index.jsp> | ||
+ | <html> | ||
+ | <body> | ||
+ | <h2>Hello World!</h2> | ||
+ | </body> | ||
+ | </html> | ||
</file> | </file> | ||
- | <file xml generatorConfig.xml> | + | ==== pom.xml ==== |
- | </file> | + | <file xml pom.xml> |
- | <file xml generatorConfig.xml> | + | <?xml version="1.0" encoding="UTF-8"?> |
+ | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
+ | <modelVersion>4.0.0</modelVersion> | ||
+ | <groupId>com.gxx</groupId> | ||
+ | <artifactId>record</artifactId> | ||
+ | <packaging>war</packaging> | ||
+ | <version>0.0.1-SNAPSHOT</version> | ||
+ | <name>record Maven Webapp</name> | ||
+ | <url>http://maven.apache.org</url> | ||
+ | |||
+ | <!-- 项目属性 --> | ||
+ | <properties> | ||
+ | <!-- jar 版本设置 --> | ||
+ | <spring.version>4.0.5.RELEASE</spring.version> | ||
+ | <aspectjrt.version>1.6.9</aspectjrt.version> | ||
+ | <aspectjweaver.version>1.6.1</aspectjweaver.version> | ||
+ | <freemarker.version>2.3.20</freemarker.version> | ||
+ | <mybatis.version>3.2.7</mybatis.version> | ||
+ | <mybatis-spring.version>1.2.2</mybatis-spring.version> | ||
+ | <mybatis-generator-core.version>1.3.2</mybatis-generator-core.version> | ||
+ | <servlet-api.version>2.4</servlet-api.version> | ||
+ | <jsp-api.version>2.0</jsp-api.version> | ||
+ | <jstl.version>1.2</jstl.version> | ||
+ | <standard.version>1.1.2</standard.version> | ||
+ | <jackson-databind.version>2.4.0</jackson-databind.version> | ||
+ | <jackson-annotations.version>2.4.0</jackson-annotations.version> | ||
+ | <jackson-module-jaxb-annotations.version>2.4.0</jackson-module-jaxb-annotations.version> | ||
+ | <jackson-core.version>2.4.0</jackson-core.version> | ||
+ | <junit.version>4.11</junit.version> | ||
+ | <log4j.version>1.2.16</log4j.version> | ||
+ | <mysql-connector-java.version>5.1.9</mysql-connector-java.version> | ||
+ | <commons-dbcp.version>1.4</commons-dbcp.version> | ||
+ | </properties> | ||
+ | |||
+ | <!-- scm软件配置管理 --> | ||
+ | <scm> | ||
+ | <connection>scm:svn:svn://121.43.104.34/gxx/trunk/record</connection> | ||
+ | <developerConnection>scm:svn:svn://121.43.104.34/gxx/trunk/record</developerConnection> | ||
+ | </scm> | ||
+ | |||
+ | <dependencies> | ||
+ | <!-- Spring --> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-core</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-beans</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-context</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-context-support</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-aop</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-jdbc</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-web</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-webmvc</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- aspectj --> | ||
+ | <dependency> | ||
+ | <groupId>org.aspectj</groupId> | ||
+ | <artifactId>aspectjrt</artifactId> | ||
+ | <version>${aspectjrt.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.aspectj</groupId> | ||
+ | <artifactId>aspectjweaver</artifactId> | ||
+ | <version>${aspectjweaver.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- freemarker --> | ||
+ | <dependency> | ||
+ | <groupId>org.freemarker</groupId> | ||
+ | <artifactId>freemarker</artifactId> | ||
+ | <version>${freemarker.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- mybatis --> | ||
+ | <dependency> | ||
+ | <groupId>org.mybatis</groupId> | ||
+ | <artifactId>mybatis</artifactId> | ||
+ | <version>${mybatis.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.mybatis</groupId> | ||
+ | <artifactId>mybatis-spring</artifactId> | ||
+ | <version>${mybatis-spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.mybatis.generator</groupId> | ||
+ | <artifactId>mybatis-generator-core</artifactId> | ||
+ | <version>${mybatis-generator-core.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- j2ee基础 --> | ||
+ | <dependency> | ||
+ | <groupId>javax.servlet</groupId> | ||
+ | <artifactId>servlet-api</artifactId> | ||
+ | <version>${servlet-api.version}</version> | ||
+ | <scope>provided</scope> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>javax.servlet.jsp</groupId> | ||
+ | <artifactId>jsp-api</artifactId> | ||
+ | <version>${jsp-api.version}</version> | ||
+ | <scope>provided</scope> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>javax.servlet</groupId> | ||
+ | <artifactId>jstl</artifactId> | ||
+ | <version>${jstl.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>taglibs</groupId> | ||
+ | <artifactId>standard</artifactId> | ||
+ | <version>${standard.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- jackson --> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.core</groupId> | ||
+ | <artifactId>jackson-databind</artifactId> | ||
+ | <version>${jackson-databind.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.core</groupId> | ||
+ | <artifactId>jackson-annotations</artifactId> | ||
+ | <version>${jackson-annotations.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.module</groupId> | ||
+ | <artifactId>jackson-module-jaxb-annotations</artifactId> | ||
+ | <version>${jackson-module-jaxb-annotations.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.core</groupId> | ||
+ | <artifactId>jackson-core</artifactId> | ||
+ | <version>${jackson-core.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- log4j --> | ||
+ | <dependency> | ||
+ | <groupId>log4j</groupId> | ||
+ | <artifactId>log4j</artifactId> | ||
+ | <version>${log4j.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- junit --> | ||
+ | <dependency> | ||
+ | <groupId>junit</groupId> | ||
+ | <artifactId>junit</artifactId> | ||
+ | <scope>test</scope> | ||
+ | <version>${junit.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- mysql --> | ||
+ | <dependency> | ||
+ | <groupId>mysql</groupId> | ||
+ | <artifactId>mysql-connector-java</artifactId> | ||
+ | <version>${mysql-connector-java.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- dbcp --> | ||
+ | <dependency> | ||
+ | <groupId>commons-dbcp</groupId> | ||
+ | <artifactId>commons-dbcp</artifactId> | ||
+ | <version>${commons-dbcp.version}</version> | ||
+ | </dependency> | ||
+ | </dependencies> | ||
+ | |||
+ | <!-- 设定除中央仓repo1.maven.org/maven2/)外的其他仓库,按设定顺序进行查 --> | ||
+ | <repositories> | ||
+ | <!-- nexus私服仓库 --> | ||
+ | <repository> | ||
+ | <id>nexus</id> | ||
+ | <name>Team Nexus Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/groups/public</url> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>offical</id> | ||
+ | <name>Maven Official Repository</name> | ||
+ | <url>http://repo1.maven.org/maven2</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>spring-milestone</id> | ||
+ | <name>Spring Maven MILESTONE Repository</name> | ||
+ | <url>http://maven.springframework.org/milestone</url> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>jboss</id> | ||
+ | <name>Jboss Repository</name> | ||
+ | <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>java.net</id> | ||
+ | <name>Java.net Repository</name> | ||
+ | <url>http://download.java.net/maven/2/</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>spring-release</id> | ||
+ | <name>Spring Maven Release Repository</name> | ||
+ | <url>http://repo.springsource.org/libs-release</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | </repositories> | ||
+ | |||
+ | <build> | ||
+ | <finalName>record</finalName> | ||
+ | <plugins> | ||
+ | <!-- jdk编译插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-compiler-plugin</artifactId> | ||
+ | <version>2.0.2</version> | ||
+ | <configuration> | ||
+ | <source>1.6</source> | ||
+ | <target>1.6</target> | ||
+ | <encoding>utf8</encoding> | ||
+ | </configuration> | ||
+ | </plugin> | ||
+ | <!-- scm软件配置管理插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-scm-plugin</artifactId> | ||
+ | <version>1.3</version> | ||
+ | </plugin> | ||
+ | <!-- 版本发布插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-release-plugin</artifactId> | ||
+ | <version>2.4</version> | ||
+ | <configuration> | ||
+ | <tagBase>svn://121.43.104.34/gxx/tags/record</tagBase> | ||
+ | <branchBase>svn://121.43.104.34/gxx/branches/record</branchBase> | ||
+ | </configuration> | ||
+ | </plugin> | ||
+ | <!-- 原型插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-archetype-plugin</artifactId> | ||
+ | <version>2.2</version> | ||
+ | </plugin> | ||
+ | </plugins> | ||
+ | </build> | ||
+ | |||
+ | <!-- 版本发布管理 --> | ||
+ | <distributionManagement> | ||
+ | <!-- release稳定版本 --> | ||
+ | <repository> | ||
+ | <id>nexus-releases</id> | ||
+ | <name>Nexus Release Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/repositories/releases/</url> | ||
+ | </repository> | ||
+ | <!-- snapshots快照版本 --> | ||
+ | <snapshotRepository> | ||
+ | <id>nexus-snapshots</id> | ||
+ | <name>Nexus Snapshot Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/repositories/snapshots/</url> | ||
+ | </snapshotRepository> | ||
+ | </distributionManagement> | ||
+ | </project> | ||
</file> | </file> | ||
+ | ===== SQL脚本 ===== | ||
+ | <code sql database.sql> | ||
+ | create database record; | ||
+ | use record; | ||
+ | CREATE TABLE `user` ( | ||
+ | `id` int(10) unsigned NOT NULL auto_increment COMMENT '主键', | ||
+ | `name` varchar(50) NOT NULL COMMENT '姓名', | ||
+ | `password` varchar(32) NOT NULL COMMENT '密码', | ||
+ | `create_date` varchar(8) NOT NULL COMMENT '创建日期', | ||
+ | `create_time` varchar(6) NOT NULL COMMENT '创建时间', | ||
+ | PRIMARY KEY (`id`) | ||
+ | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='用户表' | ||
+ | </code> | ||
+ | ===== 打包下载 ===== | ||
+ | {{:分享:技术:示例项目:record.zip|}} | ||
+ | ===== 使用说明 ===== | ||
+ | ==== 怎么在eclipse中运行项目 ==== | ||
+ | - 本地需要安装maven3 | ||
+ | - 打包下载 | ||
+ | - 导入eclipse中,自动Build Project,第一次下载maven依赖耗时较长,请耐心等待 | ||
+ | - 修改相应配置,比如log4j.properties中的绝对路径 | ||
+ | - 开启mysql,运行上面的database.sql | ||
+ | - 部署到eclipse绑定的tomcat中,启动tomcat | ||
+ | - 启动成功之后,访问http://localhost/record/,看到Hello World!,表示项目成功运行 | ||
+ | - 访问http://localhost/record/user/preRegistFtl.htm和http://localhost/record/user/preRegistJsp.htm进行测试 | ||
+ | ==== 使用mybatis-generator逆向生成框架代码 ==== | ||
+ | - 修改generatorConfig.xml中的配置 | ||
+ | - 驱动jar包路径 | ||
+ | - 数据库连接 | ||
+ | - 模型层配置 | ||
+ | - 映射配置 | ||
+ | - mapper接口配置 | ||
+ | - 需要生成的数据表配置 | ||
+ | - 运行MybatisGeneratorMain.java | ||
+ | - 刷新目标目录中是否有新文件生成vo,mapper,dao | ||
+ | - 注意:重复生成vo和dao会覆盖原文件,mapper会继续写在文件后面,所以重复生成程序运行会出错,需要手动删除再重新生成 |