一直希望能够搭建一个完整的,基础Web框架,方便日后接一些外快的时候,能够省时省力,终于花了一周的时间,把这个东西搞定了。特此写下此博客,一来是纪念,二来是希望能够为别人提供方便。顺带说一下,恩,组合框架的各个部分用的版本有的是最新的,有的则不是,不敢保证最新版本下,按照这个整合方式,不会报错...
简单介绍一下,本框架的基本功能点:
Spring:整个框架的主体部分,这个自不用说。SpringMVC:MVC部分我还是比较喜欢Spring的。MyBatis:选型的时候选择这个ORM主要也是考虑其灵活性的问题,毕竟我也不知道,今后会遇到怎样的需求,用Hibernate一来是不太会用,二来,我还是比较喜欢直接写SQL来的简单一点。SpringSecurity:这个主要是安全框架,负责用户登录验证及整站权限分配的相关事项(权限分配真的很有用,这个我就不多说了)。EhCache:一个非常流行又非常简单好用的缓存框架,并且目前已经支持分布式,如果觉得不好用,自己换成Redis也都OK。JCaptcha:一个简单的验证码生成框架(或者说工具)。Log4J:现在没人不知道这个日志框架吧...
按照这样的选型,基本可以完成大部分网站的基础框架,如:
用户登录管理,整站权限分配,数据缓存,登录验证码,数据库操作,统一异常处理,日志输出。
网上找了很多文章,大部分都是只有部分整合的,比如SSH整合,SSM整合,SpringMVC+SpringSecurity,等等,东一块,西一块,非常分散,而且每个人的配置方式还不一样,不统一,有的人喜欢注解配置,有的人喜欢XML配置,有的文章甚至直接就是有东没西,神龙见首不见尾。看的我是很郁闷,很蛋疼,因为当我好不容易搭好一个SSM框架,我发现,我要管理用户登录及权限分配的时候,咦,我还得去配置Security,然后又要找很多文章来补充知识,配置Security的时候,又要找验证码的框架,都搞好了以后,发现诶,缓存这个东西不都是任何一个网站必备的吗?所以就有了现在这篇文章,花了好大得劲,终于把所有都整合起来了。
但是,本文章,不提供项目源码!
只有自己亲手走过一遍,才真正学得会知识。作为一个程序员,我相信这样才是对我们是最好的一个方式。所以不要索要源码,不会给的。 先给出整个项目的
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/maven-v4_0_0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4 <groupId>com.magic.rent</groupId>
5 <artifactId>ssm</artifactId>
6 <packaging>war</packaging>
7 <version>1.0-SNAPSHOT</version>
8 <name>ssm Maven Webapp</name>
9 <url>http:
//maven.apache.org</url>
10 <repositories>
11 <repository>
12 <id>atlassian</id>
13 <name>atlassian</name>
14 <url>http:
//maven.jahia.org/maven2/</url>
15 </repository>
16 </repositories>
17 <build>
18 <finalName>ssm</finalName>
19 <plugins>
20 <!--Mybatis 逆向工程插件-->
21 <plugin>
22 <groupId>org.mybatis.generator</groupId>
23 <artifactId>mybatis-generator-maven-plugin</artifactId>
24 <version>1.3.2</version>
25 <configuration>
26 <verbose>
true</verbose>
27 <overwrite>
true</overwrite>
28 </configuration>
29 </plugin>
30 </plugins>
31 </build>
32 <properties>
33 <security.version>4.1.3.RELEASE</security.version>
34 <spring.version>4.3.3.RELEASE</spring.version>
35 </properties>
36 <dependencies>
37 <!-- SpringFramework Start -->
38 <dependency>
39 <groupId>org.springframework</groupId>
40 <artifactId>spring-core</artifactId>
41 <version>${spring.version}</version>
42 </dependency>
43
44 <dependency>
45 <groupId>org.springframework</groupId>
46 <artifactId>spring-web</artifactId>
47 <version>${spring.version}</version>
48 </dependency>
49
50 <dependency>
51 <groupId>org.springframework</groupId>
52 <artifactId>spring-oxm</artifactId>
53 <version>${spring.version}</version>
54 </dependency>
55
56 <dependency>
57 <groupId>org.springframework</groupId>
58 <artifactId>spring-tx</artifactId>
59 <version>${spring.version}</version>
60 </dependency>
61
62 <dependency>
63 <groupId>org.springframework</groupId>
64 <artifactId>spring-jdbc</artifactId>
65 <version>${spring.version}</version>
66 </dependency>
67
68 <dependency>
69 <groupId>org.springframework</groupId>
70 <artifactId>spring-webmvc</artifactId>
71 <version>${spring.version}</version>
72 </dependency>
73
74 <dependency>
75 <groupId>org.springframework</groupId>
76 <artifactId>spring-aop</artifactId>
77 <version>${spring.version}</version>
78 </dependency>
79
80 <dependency>
81 <groupId>org.springframework</groupId>
82 <artifactId>spring-context-support</artifactId>
83 <version>${spring.version}</version>
84 </dependency>
85
86 <dependency>
87 <groupId>org.springframework</groupId>
88 <artifactId>spring-test</artifactId>
89 <version>${spring.version}</version>
90 </dependency>
91
92 <dependency>
93 <groupId>org.springframework</groupId>
94 <artifactId>spring-expression</artifactId>
95 <version>${spring.version}</version>
96 </dependency>
97 <!-- SpringFramework End -->
98
99 <!--SpringSecurity Start-->
100 <dependency>
101 <groupId>org.springframework.security</groupId>
102 <artifactId>spring-security-core</artifactId>
103 <version>${security.version}</version>
104 </dependency>
105 <dependency>
106 <groupId>org.springframework.security</groupId>
107 <artifactId>spring-security-web</artifactId>
108 <version>${security.version}</version>
109 </dependency>
110 <dependency>
111 <groupId>org.springframework.security</groupId>
112 <artifactId>spring-security-config</artifactId>
113 <version>${security.version}</version>
114 </dependency>
115 <dependency>
116 <groupId>org.springframework.security</groupId>
117 <artifactId>spring-security-taglibs</artifactId>
118 <version>${security.version}</version>
119 </dependency>
120 <dependency>
121 <groupId>org.springframework.security</groupId>
122 <artifactId>spring-security-crypto</artifactId>
123 <version>${security.version}</version>
124 </dependency>
125 <!--SpringSecurity End-->
126
127 <!--aspectj start-->
128 <dependency>
129 <groupId>org.aspectj</groupId>
130 <artifactId>aspectjweaver</artifactId>
131 <version>1.8.6</version>
132 </dependency>
133
134 <dependency>
135 <groupId>org.aspectj</groupId>
136 <artifactId>aspectjrt</artifactId>
137 <version>1.8.6</version>
138 </dependency>
139 <!--aspectj end-->
140
141 <!--c3p0-->
142 <dependency>
143 <groupId>com.mchange</groupId>
144 <artifactId>c3p0</artifactId>
145 <version>0.9.5.1</version>
146 </dependency>
147
148 <!--servlet/jsp api start-->
149 <dependency>
150 <groupId>javax.servlet</groupId>
151 <artifactId>servlet-api</artifactId>
152 <version>2.5</version>
153 </dependency>
154
155 <dependency>
156 <groupId>javax.servlet.jsp</groupId>
157 <artifactId>jsp-api</artifactId>
158 <version>2.1</version>
159 <scope>provided</scope>
160 </dependency>
161 <!--servlet/jsp api end-->
162
163 <!--junit4-->
164 <dependency>
165 <groupId>junit</groupId>
166 <artifactId>junit</artifactId>
167 <version>4.11</version>
168 <scope>test</scope>
169 </dependency>
170
171 <!--Mybatis-->
172 <dependency>
173 <groupId>org.mybatis</groupId>
174 <artifactId>mybatis</artifactId>
175 <version>3.3.0</version>
176 </dependency>
177 <!--Mybatis Spring整合-->
178 <dependency>
179 <groupId>org.mybatis</groupId>
180 <artifactId>mybatis-spring</artifactId>
181 <version>1.2.3</version>
182 </dependency>
183
184 <!--MySQL Driver-->
185 <dependency>
186 <groupId>mysql</groupId>
187 <artifactId>mysql-connector-java</artifactId>
188 <version>5.1.6</version>
189 </dependency>
190
191 <dependency>
192 <groupId>jstl</groupId>
193 <artifactId>jstl</artifactId>
194 <version>1.2</version>
195 </dependency>
196
197 <!--JCaptcha验证码-->
198 <dependency>
199 <groupId>com.octo.captcha</groupId>
200 <artifactId>jcaptcha</artifactId>
201 <version>1.0</version>
202 </dependency>
203
204 <!--公共工具包-->
205 <dependency>
206 <groupId>org.apache.commons</groupId>
207 <artifactId>commons-lang3</artifactId>
208 <version>3.4</version>
209 </dependency>
210
211 <!--Ehcache缓存框架 start-->
212 <dependency>
213 <groupId>net.sf.ehcache</groupId>
214 <artifactId>ehcache-core</artifactId>
215 <version>2.6.11</version>
216 </dependency>
217 <!--Mybatis-Ehcache整合包-->
218 <dependency>
219 <groupId>org.mybatis</groupId>
220 <artifactId>mybatis-ehcache</artifactId>
221 <version>1.0.0</version>
222 </dependency>
223 <!--Ehcache-Web页面及对象缓存-->
224 <dependency>
225 <groupId>net.sf.ehcache</groupId>
226 <artifactId>ehcache-web</artifactId>
227 <version>2.0.4</version>
228 </dependency>
229 <dependency>
230 <groupId>org.slf4j</groupId>
231 <artifactId>slf4j-api</artifactId>
232 <version>1.6.1</version>
233 </dependency>
234 <dependency>
235 <groupId>org.slf4j</groupId>
236 <artifactId>slf4j-log4j12</artifactId>
237 <version>1.6.2</version>
238 </dependency>
239 <!--Ehcache缓存框架 end-->
240 </dependencies>
241 </project>
项目结构截图
[图是高清的,我从1080P的屏幕下截取的]
[字太小可以下载到本地后放大,可以看得很清楚,亲测]
[回头有空,我再补一个目录结构文档]
转载于:https://www.cnblogs.com/wuxinzhe/p/5922449.html
相关资源:数据结构—成绩单生成器