提交 667b7ecb 编写于 作者: Y yadong.zhang

增加启用Redis的配置项,可手动配置是否使用redis

上级 2171f973
......@@ -20,6 +20,7 @@
package com.zyd.blog.business.aspect;
import com.zyd.blog.business.annotation.RedisCache;
import com.zyd.blog.framework.config.AppPropertiesConfig;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
......@@ -55,6 +56,8 @@ public class RedisCacheAspect {
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private AppPropertiesConfig propertiesConfig;
@Pointcut(value = "@annotation(com.zyd.blog.business.annotation.RedisCache)")
public void pointcut() {
......@@ -62,6 +65,10 @@ public class RedisCacheAspect {
@Around("pointcut()")
public Object handle(ProceedingJoinPoint point) throws Throwable {
if(!propertiesConfig.getEnableRedis()){
LOGGER.info("未启用Redis");
return point.proceed();
}
// 获取拦截的方法名
Signature sig = point.getSignature();
MethodSignature msig = null;
......
......@@ -42,6 +42,12 @@ import java.util.Map;
@Data
public class AppPropertiesConfig {
public Boolean enableRedis;
public boolean getEnableRedis() {
return null == enableRedis ? false : enableRedis;
}
public Map<String, String> qiniu = new HashMap<>();
public String getQiniuAccessKey() {
......
......@@ -132,11 +132,13 @@ banner:
####################################自定义配置##########################################
app:
# 是否启用redis
enableRedis: false
qiniu:
# 七牛ACCESS_KEY
accessKey: ACCESS_KEY
# 七牛SECRET_KEY
secretKey: SECRET_KEY
# # 七牛BUCKET_NAME
# 七牛BUCKET_NAME
bucketName: BUCKET_NAME
####################################自定义配置##########################################
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册