├── .gitignore
├── README.md
├── beauty_ssm.iml
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── yingjun
│ │ └── ssm
│ │ ├── aop
│ │ └── BindingResultAop.java
│ │ ├── cache
│ │ ├── RedisCache.java
│ │ └── RedisClusterCache.java
│ │ ├── dao
│ │ ├── GoodsDao.java
│ │ ├── OrderDao.java
│ │ └── UserDao.java
│ │ ├── dto
│ │ └── BaseResult.java
│ │ ├── entity
│ │ ├── Goods.java
│ │ ├── Order.java
│ │ └── User.java
│ │ ├── enums
│ │ └── ResultEnum.java
│ │ ├── exception
│ │ ├── BizException.java
│ │ └── GlobalExceptionResolver.java
│ │ ├── quartz
│ │ └── BizQuartz.java
│ │ ├── service
│ │ ├── GoodsService.java
│ │ ├── UserService.java
│ │ └── impl
│ │ │ ├── GoodsServiceImpl.java
│ │ │ └── UserServiceImpl.java
│ │ ├── util
│ │ ├── CustomDateSerializer.java
│ │ ├── ProtoStuffSerializerUtil.java
│ │ └── TimeUtils.java
│ │ ├── validator
│ │ ├── CustomDateSerializer.java
│ │ ├── Not999.java
│ │ └── Not999Validator.java
│ │ └── web
│ │ ├── GoodsController.java
│ │ └── UserController.java
├── resources
│ ├── ValidationMessages.properties
│ ├── jdbc.properties
│ ├── log4j.properties
│ ├── mapper
│ │ ├── GoodsDao.xml
│ │ ├── OrderDao.xml
│ │ └── UserDao.xml
│ ├── mybatis-config.xml
│ ├── redis.properties
│ ├── spring
│ │ ├── spring-dao.xml
│ │ ├── spring-quartz.xml
│ │ ├── spring-redis.xml
│ │ ├── spring-service.xml
│ │ └── spring-web.xml
│ └── sql
│ │ ├── execute_bug.sql
│ │ └── schema.sql
└── webapp
│ ├── WEB-INF
│ ├── jsp
│ │ ├── common
│ │ │ ├── head.jsp
│ │ │ └── tag.jsp
│ │ ├── goodslist.jsp
│ │ └── userlist.jsp
│ └── web.xml
│ ├── index.jsp
│ └── resource
│ └── script
│ └── handler.js
└── test
└── java
└── com
└── yingjun
└── ssm
└── dao
├── GoodsDaoTest.java
├── OrderDaoTest.java
└── UserDaoTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /catalina.base_IS_UNDEFINED/
3 | /.settings/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #优雅的SSM架构(Spring+SpringMVC+Mybatis)
2 | - Maven
3 | - Spring(IOC DI AOP 声明式事务处理)
4 | - SpringMVC(支持Restful风格)
5 | - Hibernate Validate(参数校验)
6 | - Mybatis(最少配置方案)
7 | - Quartz时间调度
8 | - Redis缓存(ProtoStuff序列化)
9 | - [Redis Sentinel主从高可用方案](http://wosyingjun.iteye.com/blog/2289593)
10 | - [Redis Cluster集群高可用方案](http://wosyingjun.iteye.com/blog/2289220)
11 | - [Druid(数据源配置 sql防注入 sql性能监控)](http://wosyingjun.iteye.com/blog/2306139)
12 | - 统一的异常处理
13 | - JSP JSTL JavaScript
14 | - Sping Shiro权限控制(待完善)
15 |
16 | ###**架构图:**
17 | 
--------------------------------------------------------------------------------
/beauty_ssm.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.yingjun.ssm
5 | beauty_ssm
6 | war
7 | 0.0.1-SNAPSHOT
8 |
9 |
10 | UTF-8
11 | yyyyMMdd
12 | 4.2.0.RELEASE
13 |
14 |
15 |
16 |
17 |
18 | com.google.guava
19 | guava
20 | 18.0
21 |
22 |
23 |
24 | log4j
25 | log4j
26 | 1.2.17
27 |
28 |
29 | org.slf4j
30 | slf4j-api
31 | 1.7.5
32 |
33 |
34 | org.slf4j
35 | slf4j-log4j12
36 | 1.7.5
37 |
38 |
39 |
40 | org.apache.commons
41 | commons-lang3
42 | 3.3.2
43 |
44 |
45 |
46 | commons-io
47 | commons-io
48 | 2.4
49 |
50 |
51 |
52 | junit
53 | junit
54 | 4.12
55 |
56 |
57 |
58 | commons-collections
59 | commons-collections
60 | 3.2.1
61 |
62 |
63 |
64 | org.quartz-scheduler
65 | quartz
66 | 1.8.5
67 |
68 |
69 |
70 | com.alibaba
71 | fastjson
72 | 1.2.8
73 |
74 |
75 |
76 | org.hibernate
77 | hibernate-validator
78 | 4.2.0.Final
79 |
80 |
81 |
82 |
83 |
84 | org.springframework
85 | spring-core
86 | ${spring.version}
87 |
88 |
89 |
90 | org.springframework
91 | spring-beans
92 | ${spring.version}
93 |
94 |
95 |
96 | org.springframework
97 | spring-context
98 | ${spring.version}
99 |
100 |
101 |
102 | org.springframework
103 | spring-context-support
104 | ${spring.version}
105 |
106 |
107 |
108 | org.springframework
109 | spring-aop
110 | ${spring.version}
111 |
112 |
113 |
114 | org.springframework
115 | spring-aspects
116 | ${spring.version}
117 |
118 |
119 |
120 | org.springframework
121 | spring-expression
122 | ${spring.version}
123 |
124 |
125 |
126 | org.springframework
127 | spring-tx
128 | ${spring.version}
129 |
130 |
131 |
132 | org.springframework
133 | spring-test
134 | ${spring.version}
135 |
136 |
137 |
138 |
139 |
140 | jstl
141 | jstl
142 | 1.2
143 |
144 |
145 |
146 | javax.servlet
147 | javax.servlet-api
148 | 3.1.0
149 |
150 |
151 |
152 | taglibs
153 | standard
154 | 1.1.2
155 |
156 |
157 |
158 | org.springframework
159 | spring-web
160 | ${spring.version}
161 |
162 |
163 |
164 | org.springframework
165 | spring-webmvc
166 | ${spring.version}
167 |
168 |
169 |
170 | com.fasterxml.jackson.core
171 | jackson-databind
172 | 2.7.4
173 |
174 |
175 |
176 |
177 |
178 | mysql
179 | mysql-connector-java
180 | 5.1.38
181 | runtime
182 |
183 |
184 |
185 | com.alibaba
186 | druid
187 | 1.0.20
188 |
189 |
190 |
191 | org.springframework
192 | spring-jdbc
193 | ${spring.version}
194 |
195 |
196 |
197 | org.mybatis
198 | mybatis
199 | 3.4.0
200 |
201 |
202 |
203 | org.mybatis
204 | mybatis-spring
205 | 1.3.0
206 |
207 |
208 |
209 | redis.clients
210 | jedis
211 | 2.8.0
212 |
213 |
214 | org.springframework.data
215 | spring-data-redis
216 | 1.6.4.RELEASE
217 |
218 |
219 |
220 | com.dyuproject.protostuff
221 | protostuff-core
222 | 1.0.8
223 |
224 |
225 |
226 | com.dyuproject.protostuff
227 | protostuff-runtime
228 | 1.0.8
229 |
230 |
231 |
232 |
233 |
234 |
235 | ${project.artifactId}_${project.version}_${maven.build.timestamp}
236 |
237 |
238 |
239 | src/main/resources
240 |
241 | true
242 |
243 |
244 |
245 |
246 | maven-compiler-plugin
247 | 2.3.2
248 |
249 | 1.7
250 | 1.7
251 |
252 |
253 |
254 | org.apache.maven.plugins
255 | maven-war-plugin
256 | 2.6
257 |
258 |
259 |
260 |
261 |
--------------------------------------------------------------------------------
/src/main/java/com/yingjun/ssm/aop/BindingResultAop.java:
--------------------------------------------------------------------------------
1 | package com.yingjun.ssm.aop;
2 |
3 | import com.yingjun.ssm.dto.BaseResult;
4 | import org.aspectj.lang.ProceedingJoinPoint;
5 | import org.aspectj.lang.annotation.Around;
6 | import org.aspectj.lang.annotation.Aspect;
7 | import org.aspectj.lang.annotation.Pointcut;
8 | import org.slf4j.Logger;
9 | import org.slf4j.LoggerFactory;
10 | import org.springframework.stereotype.Component;
11 | import org.springframework.validation.BindingResult;
12 |
13 | /**
14 | * @author yingjun
15 | *
16 | * 采用AOP的方式处理参数问题。
17 | */
18 | @Component
19 | @Aspect
20 | public class BindingResultAop {
21 |
22 | private final Logger LOG = LoggerFactory.getLogger(this.getClass());
23 |
24 | @Pointcut("execution(* com.yingjun.ssm.web.*.*(..))")
25 | public void aopMethod(){}
26 |
27 | @Around("aopMethod()")
28 | public Object around(ProceedingJoinPoint joinPoint) throws Throwable{
29 | LOG.info("before method invoking!");
30 | BindingResult bindingResult = null;
31 | for(Object arg:joinPoint.getArgs()){
32 | if(arg instanceof BindingResult){
33 | bindingResult = (BindingResult) arg;
34 | }
35 | }
36 | if(bindingResult != null){
37 | if(bindingResult.hasErrors()){
38 | String errorInfo="["+bindingResult.getFieldError().getField()+"]"+bindingResult.getFieldError().getDefaultMessage();
39 | return new BaseResult