https://crossoverjie.top/2017/05/24/SSM14/
基于annotation的http去重插件:
Redis
保存请求。Spring AOP
进行切面。
后续会用Spring Boot
重构
https://github.com/crossoverJie/SSM-REQUEST-CHECK.git
cd SSM-REQUEST-CHECK
mvn clean
mvn install
<dependency>
<groupId>com.crossoverJie</groupId>
<artifactId>SSM-REQUEST-CHECK</artifactId>
<version>1.0.0</version>
</dependency>
需要根据自己
web.xml
中定义的
<!-- Spring MVC servlet -->
<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
spring-mvc.xml
文件中配置:
<aop:aspectj-autoproxy proxy-target-class="true"></aop:aspectj-autoproxy>
@CheckReqNo
@RequestMapping(value = "/createRedisContent",method = RequestMethod.POST)
@ResponseBody
public BaseResponse<NULLBody> createRedisContent(@RequestBody RedisContentReq redisContentReq){
BaseResponse<NULLBody> response = new BaseResponse<NULLBody>() ;
Rediscontent rediscontent = new Rediscontent() ;
try {
CommonUtil.setLogValueModelToModel(redisContentReq,rediscontent);
rediscontentMapper.insertSelective(rediscontent) ;
response.setReqNo(redisContentReq.getReqNo());
response.setCode(StatusEnum.SUCCESS.getCode());
response.setMessage(StatusEnum.SUCCESS.getMessage());
}catch (Exception e){
logger.error("system error",e);
response.setReqNo(response.getReqNo());
response.setCode(StatusEnum.FAIL.getCode());
response.setMessage(StatusEnum.FAIL.getMessage());
}
return response ;
}
默认缓存前缀是
reqNo
,时间为1天。
#redis前缀
redis.prefixReq=reqNo
#redis缓存时间 默认单位为天
redis.day=1