索引: 開源Spring解決方案--lm.solution 參看代碼 GitHub: solution/pom.xml web/pom.xml web.xml WebInitializer.java WebConfig.java RootConfig.java 一、引入必要類庫 spring-con ...
索引:
參看代碼 GitHub:
一、引入必要類庫
spring-context
spring-context-support
spring-webmvc:引入該包後,maven 會自動解析依賴,引入 spring-web 等包。
1.solution/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 5 <groupId>lm.solution</groupId> 6 <artifactId>solution</artifactId> 7 <version>1.0-SNAPSHOT</version> 8 <modules> 9 <module>webapi</module> 10 <module>web</module> 11 <module>common</module> 12 <module>service</module> 13 <module>mapper</module> 14 <module>pojo</module> 15 <module>console</module> 16 <module>webservice</module> 17 </modules> 18 <packaging>pom</packaging> 19 20 <name>solution</name> 21 <url>http://maven.apache.org</url> 22 23 <properties> 24 <!--編譯字元集--> 25 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 26 <!-- spring --> 27 <spring.version>4.3.13.RELEASE</spring.version> 28 <!-- log4j --> 29 <slf4j.version>1.7.7</slf4j.version> 30 <log4j.version>1.2.17</log4j.version> 31 <!-- jackson --> 32 <jackson.version>2.9.4</jackson.version> 33 <!-- junit --> 34 <junit.version>4.12</junit.version> 35 <!-- aspectj --> 36 <aspectj.version>1.8.13</aspectj.version> 37 <!-- cglib --> 38 <cglib.version>3.1</cglib.version> 39 <!-- mybatis --> 40 <mybatis.version>3.4.5</mybatis.version> 41 <!-- mybatis-spring --> 42 <mybatisSpring.version>1.3.1</mybatisSpring.version> 43 <!--mysql-connector--> 44 <mysql.version>5.1.34</mysql.version> 45 <!--druid--> 46 <druid.version>1.0.5</druid.version> 47 <!--javax.servlet--> 48 <javaxServlet.version>3.0.1</javaxServlet.version> 49 <!--jsp-api--> 50 <jspApi.version>2.2</jspApi.version> 51 <!--jstl--> 52 <jstl.version>1.2</jstl.version> 53 <!--json-lib--> 54 <jsonLib.version>2.1</jsonLib.version> 55 <!--jackson old--> 56 <jacksonOld.version>1.9.13</jacksonOld.version> 57 <!--dom4j--> 58 <dom4j.version>1.6.1</dom4j.version> 59 <!--ehcache core--> 60 <ehcacheCore.version>2.6.9</ehcacheCore.version> 61 <!--ehcache web--> 62 <ehcacheWeb.version>2.0.4</ehcacheWeb.version> 63 <!--commons-fileupload--> 64 <commonsFileupload.version>1.3.1</commonsFileupload.version> 65 <!--commons-io--> 66 <commonsIo.version>2.4</commonsIo.version> 67 <!--commons-codec--> 68 <commonsCodec.version>1.9</commonsCodec.version> 69 <!--commons-collections4--> 70 <commonsCollections4.version>4.0</commonsCollections4.version> 71 <!--commons-beanutils--> 72 <commonsBeanutils.version>1.7.0</commonsBeanutils.version> 73 <!--freemarker--> 74 <freemarker.version>2.3.19</freemarker.version> 75 <!-- poi poi-ooxml --> 76 <poi.version>3.9</poi.version> 77 <!--org.apache.httpcomponents--> 78 <httpcore.version>4.4.8</httpcore.version> 79 <httpclient.version>4.5.4</httpclient.version> 80 <!-- jaxws-rt --> 81 <jaxwsRt.version>2.3.0</jaxwsRt.version> 82 <!-- jedis --> 83 <jedis.version>2.9.0</jedis.version> 84 <!-- rabbitmq --> 85 <amqpClient.version>5.1.2</amqpClient.version> 86 <!--fastjson--> 87 <fastjson.version>1.2.46</fastjson.version> 88 <!-- jsr250 --> 89 <jsr250.version>1.0</jsr250.version> 90 </properties> 91 92 <dependencies> 93 <!--單元測試依賴 --> 94 <dependency> 95 <groupId>junit</groupId> 96 <artifactId>junit</artifactId> 97 <version>RELEASE</version> 98 <!--test 說明這個包的存活是在test周期,也就是發佈時將不包含這個jar包--> 99 <scope>test</scope> 100 </dependency> 101 <!--spring單元測試依賴 --> 102 <dependency> 103 <groupId>org.springframework</groupId> 104 <artifactId>spring-test</artifactId> 105 <version>${spring.version}</version> 106 <scope>test</scope> 107 </dependency> 108 <!-- spring --> 109 <dependency> 110 <groupId>org.springframework</groupId> 111 <!-- 因依賴 會自動引入 spring-aop spring-beans spring-core spring-expression 四個包 --> 112 <artifactId>spring-context</artifactId> 113 <version>${spring.version}</version> 114 </dependency> 115 <dependency> 116 <groupId>org.springframework</groupId> 117 <artifactId>spring-context-support</artifactId> 118 <version>${spring.version}</version> 119 </dependency> 120 <dependency> 121 <groupId>org.springframework</groupId> 122 <artifactId>spring-aspects</artifactId> 123 <version>${spring.version}</version> 124 </dependency> 125 <dependency> 126 <groupId>org.springframework</groupId> 127 <artifactId>spring-tx</artifactId> 128 <version>${spring.version}</version> 129 </dependency> 130 <dependency> 131 <groupId>org.springframework</groupId> 132 <artifactId>spring-jdbc</artifactId> 133 <version>${spring.version}</version> 134 </dependency> 135 <!-- aspectj AOP --> 136 <dependency> 137 <groupId>org.aspectj</groupId> 138 <artifactId>aspectjrt</artifactId> 139 <version>${aspectj.version}</version> 140 </dependency> 141 <dependency> 142 <groupId>org.aspectj</groupId> 143 <artifactId>aspectjweaver</artifactId> 144 <version>${aspectj.version}</version> 145 </dependency> 146 <!-- 映入JSON jackson --> 147 <dependency> 148 <groupId>com.fasterxml.jackson.core</groupId> 149 <artifactId>jackson-annotations</artifactId> 150 <version>${jackson.version}</version> 151 </dependency> 152 <dependency> 153 <groupId>com.fasterxml.jackson.core</groupId> 154 <artifactId>jackson-databind</artifactId> 155 <version>${jackson.version}</version> 156 </dependency> 157 <dependency> 158 <groupId>com.fasterxml.jackson.core</groupId> 159 <artifactId>jackson-core</artifactId> 160 <version>${jackson.version}</version> 161 </dependency> 162 <dependency> 163 <groupId>com.fasterxml.jackson.dataformat</groupId> 164 <artifactId>jackson-dataformat-xml</artifactId> 165 <version>${jackson.version}</version> 166 </dependency> 167 <!-- 日誌文件管理包 --> 168 <dependency> 169 <groupId>log4j</groupId> 170 <artifactId>log4j</artifactId> 171 <version>${log4j.version}</version> 172 </dependency> 173 <dependency> 174 <groupId>org.slf4j</groupId> 175 <artifactId>slf4j-api</artifactId> 176 <version>${slf4j.version}</version> 177 </dependency> 178 <dependency> 179 <groupId>org.slf4j</groupId> 180 <artifactId>slf4j-log4j12</artifactId> 181 <version>${slf4j.version}</version> 182 </dependency> 183 </dependencies> 184 185 <dependencyManagement> 186 <dependencies> 187 <!--spring web--> 188 <dependency> 189 <groupId>org.springframework</groupId> 190 <artifactId>spring-web</artifactId> 191 <version>${spring.version}</version> 192 </dependency> 193 <dependency> 194 <groupId>org.springframework</groupId> 195 <artifactId>spring-webmvc</artifactId> 196 <version>${spring.version}</version> 197 </dependency> 198 <!--cglib--> 199 <dependency> 200 <groupId>cglib</groupId> 201 <artifactId>cglib</artifactId> 202 <version>${cglib.version}</version> 203 </dependency> 204 <!-- mybatis --> 205 <dependency> 206 <groupId>org.mybatis</groupId> 207 <artifactId>mybatis</artifactId> 208 <version>${mybatis.version}</version> 209 </dependency> 210 <dependency> 211 <groupId>org.mybatis</groupId> 212 <artifactId>mybatis-spring</artifactId> 213 <version>${mybatisSpring.version}</version> 214 </dependency> 215 <!-- Mysql資料庫驅動包 --> 216 <dependency> 217 <groupId>mysql</groupId> 218 <artifactId>mysql-connector-java</artifactId> 219 <version>${mysql.version}</version> 220 </dependency> 221 <!-- connection pool --> 222 <dependency> 223 <groupId>com.alibaba</groupId> 224 <artifactId>druid</artifactId> 225 <version>${druid.version}</version> 226 <!--<scope>runtime</scope>--> 227 </dependency> 228 <!--servlet--> 229 <dependency> 230 <groupId>javax.servlet</groupId> 231 <artifactId>javax.servlet-api</artifactId> 232 <version>${javaxServlet.version}</version> 233 <scope>provided</scope> 234 </dependency> 235 <dependency> 236 <groupId>javax.servlet.jsp</groupId> 237 <artifactId>jsp-api</artifactId> 238 <version>${jspApi.version}</version> 239 <scope>provided</scope> 240 </dependency> 241 <dependency> 242 <groupId>javax.servlet</groupId> 243 <artifactId>jstl</artifactId> 244 <version>${jstl.version}</version> 245 </dependency> 246 <!-- 映入JSON lib --> 247 <dependency> 248 <groupId>net.sf.json-lib</groupId>