diff --git a/mall-security/pom.xml b/mall-security/pom.xml
index 1ed891e..68b15ad 100644
--- a/mall-security/pom.xml
+++ b/mall-security/pom.xml
@@ -29,6 +29,10 @@
org.springframework.boot
spring-boot-starter-security
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
io.jsonwebtoken
jjwt
diff --git a/mall-security/src/main/java/com/macro/mall/security/annotation/CacheException.java b/mall-security/src/main/java/com/macro/mall/security/annotation/CacheException.java
new file mode 100644
index 0000000..615fbeb
--- /dev/null
+++ b/mall-security/src/main/java/com/macro/mall/security/annotation/CacheException.java
@@ -0,0 +1,12 @@
+package com.macro.mall.security.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义注解,有该注解的缓存方法会抛出异常
+ */
+@Documented
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CacheException {
+}
diff --git a/mall-security/src/main/java/com/macro/mall/security/aspect/RedisCacheAspect.java b/mall-security/src/main/java/com/macro/mall/security/aspect/RedisCacheAspect.java
new file mode 100644
index 0000000..abd8d9e
--- /dev/null
+++ b/mall-security/src/main/java/com/macro/mall/security/aspect/RedisCacheAspect.java
@@ -0,0 +1,50 @@
+package com.macro.mall.security.aspect;
+
+import com.macro.mall.security.annotation.CacheException;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.Signature;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Method;
+
+/**
+ * Redis缓存切面,防止Redis宕机影响正常业务逻辑
+ * Created by macro on 2020/3/17.
+ */
+@Aspect
+@Component
+@Order(2)
+public class RedisCacheAspect {
+ private static Logger LOGGER = LoggerFactory.getLogger(RedisCacheAspect.class);
+
+ @Pointcut("execution(public * com.macro.mall.portal.service.*CacheService.*(..)) || execution(public * com.macro.mall.service.*CacheService.*(..))")
+ public void cacheAspect() {
+ }
+
+ @Around("cacheAspect()")
+ public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
+ Signature signature = joinPoint.getSignature();
+ MethodSignature methodSignature = (MethodSignature) signature;
+ Method method = methodSignature.getMethod();
+ Object result = null;
+ try {
+ result = joinPoint.proceed();
+ } catch (Throwable throwable) {
+ //有CacheException注解的方法需要抛出异常
+ if (method.isAnnotationPresent(CacheException.class)) {
+ throw throwable;
+ } else {
+ LOGGER.error(throwable.getMessage());
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/mall-security/src/main/java/com/macro/mall/security/config/RedisConfig.java b/mall-security/src/main/java/com/macro/mall/security/config/RedisConfig.java
new file mode 100644
index 0000000..faf6912
--- /dev/null
+++ b/mall-security/src/main/java/com/macro/mall/security/config/RedisConfig.java
@@ -0,0 +1,63 @@
+package com.macro.mall.security.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+import java.time.Duration;
+
+/**
+ * Redis配置类
+ * Created by macro on 2020/3/2.
+ */
+@EnableCaching
+@Configuration
+public class RedisConfig extends CachingConfigurerSupport {
+
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ RedisSerializer