本节介绍如何环境的搭建和配置:
首先要在父工程引入jar包依赖:
1 <!-- 通过属性定义指定jar的版本 --> 2 <properties> 3 <spring.version>4.2.4.RELEASE</spring.version> 4 <hibernate.version>5.0.7.Final</hibernate.version> 5 <struts2.version>2.3.24</struts2.version> 6 <slf4j.version>1.6.6</slf4j.version> 7 <log4j.version>1.2.12</log4j.version> 8 <shiro.version>1.2.3</shiro.version> 9 <jackson.version>2.7.4</jackson.version> 10 <shiro.version>1.4.0</shiro.version> 11 </properties> 12 13 <dependencies> 14 <dependency> 15 <groupId>org.springframework</groupId> 16 <artifactId>spring-context</artifactId> 17 <version>${spring.version}</version> 18 </dependency> 19 20 <dependency> 21 <groupId>org.springframework</groupId> 22 <artifactId>spring-context-support</artifactId> 23 <version>${spring.version}</version> 24 </dependency> 25 26 <dependency> 27 <groupId>org.springframework</groupId> 28 <artifactId>spring-webmvc</artifactId> 29 <version>${spring.version}</version> 30 </dependency> 31 32 <dependency> 33 <groupId>org.springframework</groupId> 34 <artifactId>spring-web</artifactId> 35 <version>${spring.version}</version> 36 </dependency> 37 38 <dependency> 39 <groupId>org.springframework</groupId> 40 <artifactId>spring-orm</artifactId> 41 <version>${spring.version}</version> 42 </dependency> 43 44 <dependency> 45 <groupId>org.springframework</groupId> 46 <artifactId>spring-beans</artifactId> 47 <version>${spring.version}</version> 48 </dependency> 49 50 <dependency> 51 <groupId>org.springframework</groupId> 52 <artifactId>spring-core</artifactId> 53 <version>${spring.version}</version> 54 </dependency> 55 56 <dependency> 57 <groupId>org.mybatis</groupId> 58 <artifactId>mybatis</artifactId> 59 <version>3.3.0</version> 60 </dependency> 61 <dependency> 62 <groupId>org.mybatis</groupId> 63 <artifactId>mybatis-spring</artifactId> 64 <version>1.2.3</version> 65 </dependency> 66 67 <dependency> 68 <groupId>org.aspectj</groupId> 69 <artifactId>aspectjweaver</artifactId> 70 <version>1.7.4</version> 71 </dependency> 72 73 <!-- struts2 begin --> 74 <dependency> 75 <groupId>org.apache.struts</groupId> 76 <artifactId>struts2-core</artifactId> 77 <version>${struts2.version}</version> 78 <!-- 排除传递的依赖 --> 79 <exclusions> 80 <exclusion> 81 <artifactId>javassist</artifactId> 82 <groupId>javassist</groupId> 83 </exclusion> 84 </exclusions> 85 </dependency> 86 <dependency> 87 <groupId>org.apache.struts</groupId> 88 <artifactId>struts2-spring-plugin</artifactId> 89 <version>${struts2.version}</version> 90 </dependency> 91 <dependency> 92 <groupId>org.apache.struts</groupId> 93 <artifactId>struts2-convention-plugin</artifactId> 94 <version>${struts2.version}</version> 95 </dependency> 96 <!-- struts2 end --> 97 98 <!-- hibernate begin --> 99 <dependency> 100 <groupId>org.hibernate</groupId> 101 <artifactId>hibernate-core</artifactId> 102 <version>${hibernate.version}</version> 103 </dependency> 104 <!-- JSR-303 jar包 --> 105 <dependency> 106 <groupId>org.hibernate</groupId> 107 <artifactId>hibernate-validator</artifactId> 108 <version>5.1.3.Final</version> 109 </dependency> 110 <!-- hibernate end --> 111 112 <!-- log start --> 113 <dependency> 114 <groupId>log4j</groupId> 115 <artifactId>log4j</artifactId> 116 <version>${log4j.version}</version> 117 </dependency> 118 119 <dependency> 120 <groupId>org.slf4j</groupId> 121 <artifactId>slf4j-api</artifactId> 122 <version>${slf4j.version}</version> 123 </dependency> 124 125 <dependency> 126 <groupId>org.slf4j</groupId> 127 <artifactId>slf4j-log4j12</artifactId> 128 <version>${slf4j.version}</version> 129 </dependency> 130 <!-- log end --> 131 132 <dependency> 133 <groupId>org.apache.poi</groupId> 134 <artifactId>poi</artifactId> 135 <version>3.11</version> 136 </dependency> 137 138 <dependency> 139 <groupId>org.apache.cxf</groupId> 140 <artifactId>cxf-rt-frontend-jaxws</artifactId> 141 <version>3.0.1</version> 142 </dependency> 143 <dependency> 144 <groupId>org.apache.cxf</groupId> 145 <artifactId>cxf-rt-transports-http</artifactId> 146 <version>3.0.1</version> 147 </dependency> 148 <dependency> 149 <groupId>junit</groupId> 150 <artifactId>junit</artifactId> 151 <version>4.12</version> 152 <scope>test</scope> 153 </dependency> 154 155 <!-- 加入servlet和jsp的依赖 --> 156 <dependency> 157 <groupId>javax.servlet</groupId> 158 <artifactId>servlet-api</artifactId> 159 <version>2.5</version> 160 <scope>provided</scope> 161 </dependency> 162 <dependency> 163 <groupId>javax.servlet</groupId> 164 <artifactId>jsp-api</artifactId> 165 <version>2.0</version> 166 <scope>provided</scope> 167 </dependency> 168 169 <dependency> 170 <groupId>javax.servlet</groupId> 171 <artifactId>jstl</artifactId> 172 <version>1.2</version> 173 </dependency> 174 175 <!-- 引入fastjson的依赖 --> 176 <dependency> 177 <groupId>com.alibaba</groupId> 178 <artifactId>fastjson</artifactId> 179 <version>1.2.4</version> 180 </dependency> 181 182 <!--jackson依赖--> 183 <dependency> 184 <groupId>com.fasterxml.jackson.core</groupId> 185 <artifactId>jackson-databind</artifactId> 186 <version>${jackson.version}</version> 187 </dependency> 188 <dependency> 189 <groupId>com.fasterxml.jackson.core</groupId> 190 <artifactId>jackson-core</artifactId> 191 <version>${jackson.version}</version> 192 </dependency> 193 <dependency> 194 <groupId>com.fasterxml.jackson.core</groupId> 195 <artifactId>jackson-annotations</artifactId> 196 <version>${jackson.version}</version> 197 </dependency> 198 199 <!-- 引入pinyin4J的依赖 --> 200 <dependency> 201 <groupId>com.belerweb</groupId> 202 <artifactId>pinyin4j</artifactId> 203 <version>2.5.0</version> 204 </dependency> 205 206 <!--apache shiro jar包--> 207 <dependency> 208 <groupId>org.apache.shiro</groupId> 209 <artifactId>shiro-core</artifactId> 210 <version>${shiro.version}</version> 211 </dependency> 212 213 <!-- 引入json-lib的依赖 --> 214 <dependency> 215 <groupId>net.sf.json-lib</groupId> 216 <artifactId>json-lib</artifactId> 217 <version>2.4</version> 218 <classifier>jdk15</classifier> 219 </dependency> 220 221 <!-- 引入c3p0jar包 --> 222 <dependency> 223 <groupId>c3p0</groupId> 224 <artifactId>c3p0</artifactId> 225 <version>0.9.1.2</version> 226 </dependency> 227 228 <!-- 引入ehcache的依赖 --> 229 <dependency> 230 <groupId>net.sf.ehcache</groupId> 231 <artifactId>ehcache-core</artifactId> 232 <version>2.6.6</version> 233 </dependency> 234 <!-- 引入MySQL数据库驱动依赖 --> 235 <dependency> 236 <groupId>mysql</groupId> 237 <artifactId>mysql-connector-java</artifactId> 238 <version>5.1.32</version> 239 </dependency> 240 <dependency> 241 <groupId>org.quartz-scheduler</groupId> 242 <artifactId>quartz</artifactId> 243 <version>2.2.3</version> 244 </dependency> 245 <dependency> 246 <groupId>org.quartz-scheduler</groupId> 247 <artifactId>quartz-jobs</artifactId> 248 <version>2.2.3</version> 249 </dependency> 250 <dependency> 251 <groupId>javax.mail</groupId> 252 <artifactId>mail</artifactId> 253 <version>1.4</version> 254 </dependency> 255 </dependencies> 256 257 <build> 258 <!-- 插件 --> 259 <plugins> 260 <plugin> 261 <groupId>org.apache.maven.plugins</groupId> 262 <artifactId>maven-resources-plugin</artifactId> 263 <version>2.5</version> 264 </plugin> 265 <plugin> 266 <groupId>org.apache.maven.plugins</groupId> 267 <artifactId>maven-compiler-plugin</artifactId> 268 <version>2.3.2</version> 269 <configuration> 270 <source>1.8</source> 271 <target>1.8</target> 272 </configuration> 273 </plugin> 274 <!-- 引入tomcat插件 --> 275 <plugin> 276 <groupId>org.apache.tomcat.maven</groupId> 277 <artifactId>tomcat7-maven-plugin</artifactId> 278 <version>2.2</version> 279 <configuration> 280 <path>/</path> 281 <port>8888</port> 282 </configuration> 283 </plugin> 284 </plugins> 285 <resources> 286 <resource> 287 <directory>src/main/java</directory> 288 <includes> 289 <include>**/*.properties</include> 290 <include>**/*.xml</include> 291 </includes> 292 <filtering>false</filtering> 293 </resource> 294 <resource> 295 <directory>src/main/resources</directory> 296 <includes> 297 <include>**/*.properties</include> 298 <include>**/*.xml</include> 299 </includes> 300 <filtering>false</filtering> 301 </resource> 302 </resources> 303 </build>