欢迎转载交流:http://www.cnblogs.com/shizhongtao/p/3472864.html
这里我将展示如何用maven快速创建一个基于spring的web框架。创建步骤和上一篇差不多,只是在选择maven模板时候,选择的不一样。
- 穿件maven应用程序,在旋转模板时候,选择web模板,如下图
- 配置pom文件,加入spring的引用,pom文件如下:
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/maven-v4_0_0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 <groupId>com.bing</groupId> 5 <artifactId>spring-resource</artifactId> 6 <packaging>war</packaging> 7 <version>0.0.1-SNAPSHOT</version> 8 <name>spring-resource Maven Webapp</name> 9 <url>http://maven.apache.org</url> 10 <properties> 11 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 12 <springframework.version>3.2.4.RELEASE</springframework.version> 13 <slf4j.version>1.7.5</slf4j.version> 14 <finalName>springlog</finalName> 15 </properties> 16 <dependencies> 17 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> 18 <version>4.8</version> <scope>test</scope> </dependency> 19 <dependency> 20 <groupId>org.springframework</groupId> 21 <artifactId>spring-core</artifactId> 22 <version>${springframework.version}</version> 23 </dependency> 24 <dependency> 25 <groupId>org.springframework</groupId> 26 <artifactId>spring-beans</artifactId> 27 <version>${springframework.version}</version> 28 </dependency> 29 <dependency> 30 <groupId>org.springframework</groupId> 31 <artifactId>spring-tx</artifactId> 32 <version>${springframework.version}</version> 33 </dependency> 34 <dependency> 35 <groupId>org.springframework</groupId> 36 <artifactId>spring-context</artifactId> 37 <version>${springframework.version}</version> 38 39 <exclusions> 40 <exclusion> 41 <groupId>commons-logging</groupId> 42 <artifactId>commons-logging</artifactId> 43 </exclusion> 44 </exclusions> 45 </dependency> 46 <dependency> 47 <groupId>org.springframework</groupId> 48 <artifactId>spring-context-support</artifactId> 49 <version>${springframework.version}</version> 50 </dependency> 51 <dependency> 52 <groupId>org.springframework</groupId> 53 <artifactId>spring-web</artifactId> 54 <version>${springframework.version}</version> 55 </dependency> 56 <dependency> 57 <groupId>org.springframework</groupId> 58 <artifactId>spring-webmvc</artifactId> 59 <version>${springframework.version}</version> 60 </dependency> 61 <dependency> 62 <groupId>org.springframework</groupId> 63 <artifactId>spring-aop</artifactId> 64 <version>${springframework.version}</version> 65 </dependency> 66 <dependency> 67 <groupId>org.springframework</groupId> 68 <artifactId>spring-aspects</artifactId> 69 <version>${springframework.version}</version> 70 </dependency> 71 <dependency> 72 <groupId>org.springframework</groupId> 73 <artifactId>spring-test</artifactId> 74 <version>${springframework.version}</version> 75 </dependency> 76 <dependency> 77 <groupId>org.springframework</groupId> 78 <artifactId>spring-expression</artifactId> 79 <version>${springframework.version}</version> 80 </dependency> 81 82 <dependency> 83 <groupId>org.springframework</groupId> 84 <artifactId>spring-jdbc</artifactId> 85 <version>${springframework.version}</version> 86 </dependency> 87 <dependency> 88 <groupId>org.slf4j</groupId> 89 <artifactId>jcl-over-slf4j</artifactId> 90 <version>${slf4j.version}</version> 91 </dependency> 92 <dependency> 93 <groupId>org.slf4j</groupId> 94 <artifactId>slf4j-api</artifactId> 95 <version>${slf4j.version}</version> 96 </dependency> 97 <dependency> 98 <groupId>org.slf4j</groupId> 99 <artifactId>slf4j-log4j12</artifactId> 100 <version>${slf4j.version}</version> 101 </dependency> 102 <dependency> 103 <groupId>log4j</groupId> 104 <artifactId>log4j</artifactId> 105 <version>1.2.17</version> 106 </dependency> 107 <dependency> 108 <groupId>javax.servlet</groupId> 109 <artifactId>jstl</artifactId> 110 <version>1.2</version> 111 </dependency> 112 <dependency> 113 <groupId>javax.servlet</groupId> 114 <artifactId>servlet-api</artifactId> 115 <version>2.4</version> 116 <scope>provided</scope> 117 </dependency> 118 </dependencies> 119 <build> 120 <finalName>spring-resource</finalName> 121 </build> 122 </project>
- 然后就可以像正常的web项目一样。配置web.cml和spring的配置文件来进行项目开发了