) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]);
+ return ReflectionUtil.getSuperClassGenricType(getClass());
+ }
+
+ /**
+ * 获取MongoDB模板操作
+ *
+ * @return
+ */
+ @Override
+ public MongoTemplate getMongoTemplate() {
+ return mongoTemplate;
+ }
+
+}
diff --git a/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/util/ReflectionUtil.java b/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/util/ReflectionUtil.java
new file mode 100644
index 00000000..98f8194d
--- /dev/null
+++ b/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/util/ReflectionUtil.java
@@ -0,0 +1,246 @@
+package vip.mate.core.mongodb.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
+import java.lang.reflect.*;
+
+/**
+ * 反射工具类
+ *
+ * 提供访问私有变量,获取泛型类型Class, 提取集合中元素的属性, 转换字符串到对象等Util函数.
+ *
+ *
+ * @author pangu
+ * @date 2020-10-20
+ */
+@Slf4j
+public class ReflectionUtil {
+
+ /**
+ * 调用Getter方法.
+ */
+ public static Object invokeGetterMethod(Object obj, String propertyName) {
+ String getterMethodName = "get" + StringUtils.capitalize(propertyName);
+ return invokeMethod(obj, getterMethodName, new Class[]{}, new Object[]{});
+ }
+
+ /**
+ * 调用Setter方法.使用value的Class来查找Setter方法.
+ */
+ public static void invokeSetterMethod(Object obj, String propertyName, Object value) {
+ invokeSetterMethod(obj, propertyName, value, null);
+ }
+
+ /**
+ * 调用Setter方法.
+ *
+ * @param propertyType 用于查找Setter方法,为空时使用value的Class替代.
+ */
+ public static void invokeSetterMethod(Object obj, String propertyName, Object value, Class> propertyType) {
+ Class> type = propertyType != null ? propertyType : value.getClass();
+ String setterMethodName = "set" + StringUtils.capitalize(propertyName);
+ invokeMethod(obj, setterMethodName, new Class[]{type}, new Object[]{value});
+ }
+
+ /**
+ * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数.
+ */
+ public static Object getFieldValue(final Object obj, final String fieldName) {
+ Field field = getAccessibleField(obj, fieldName);
+
+ if (field == null) {
+ throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+ }
+
+ Object result = null;
+ try {
+ result = field.get(obj);
+ } catch (IllegalAccessException e) {
+ log.error("不可能抛出的异常{}", e.getMessage());
+ }
+ return result;
+ }
+
+ /**
+ * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数.
+ */
+ public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
+ Field field = getAccessibleField(obj, fieldName);
+
+ if (field == null) {
+ throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
+ }
+
+ try {
+ field.set(obj, value);
+ } catch (IllegalAccessException e) {
+ log.error("不可能抛出的异常:{}", e.getMessage());
+ }
+ }
+
+ /**
+ * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问.
+ *
+ * 如向上转型到Object仍无法找到, 返回null.
+ */
+ public static Field getAccessibleField(final Object obj, final String fieldName) {
+ Assert.notNull(obj, "object不能为空");
+ Assert.hasText(fieldName, "fieldName");
+ for (Class> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
+ try {
+ Field field = superClass.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ return field;
+ } catch (NoSuchFieldException e) {//NOSONAR
+ // Field不在当前类定义,继续向上转型
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 直接调用对象方法, 无视private/protected修饰符.
+ * 用于一次性调用的情况.
+ */
+ public static Object invokeMethod(final Object obj, final String methodName, final Class>[] parameterTypes,
+ final Object[] args) {
+ Method method = getAccessibleMethod(obj, methodName, parameterTypes);
+ if (method == null) {
+ throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
+ }
+
+ try {
+ return method.invoke(obj, args);
+ } catch (Exception e) {
+ throw convertReflectionExceptionToUnchecked(e);
+ }
+ }
+
+ /**
+ * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
+ * 如向上转型到Object仍无法找到, 返回null.
+ *
+ * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
+ */
+ public static Method getAccessibleMethod(final Object obj, final String methodName,
+ final Class>... parameterTypes) {
+ Assert.notNull(obj, "object不能为空");
+
+ for (Class> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
+ try {
+ Method method = superClass.getDeclaredMethod(methodName, parameterTypes);
+
+ method.setAccessible(true);
+
+ return method;
+
+ } catch (NoSuchMethodException e) {//NOSONAR
+ // Method不在当前类定义,继续向上转型
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
+ * 如无法找到, 返回Object.class.
+ * eg.
+ * public UserDao extends HibernateDao
+ *
+ * @param clazz The class to introspect
+ * @return the first generic declaration, or Object.class if cannot be determined
+ */
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public static Class getSuperClassGenricType(final Class clazz) {
+ return getSuperClassGenricType(clazz, 0);
+ }
+
+ /**
+ * 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
+ * 如无法找到, 返回Object.class.
+ *
+ * 如public UserDao extends HibernateDao
+ *
+ * @param clazz clazz The class to introspect
+ * @param index the Index of the generic ddeclaration,start from 0.
+ * @return the index generic declaration, or Object.class if cannot be determined
+ */
+ @SuppressWarnings("rawtypes")
+ public static Class getSuperClassGenricType(final Class clazz, final int index) {
+
+ Type genType = clazz.getGenericSuperclass();
+
+ if (!(genType instanceof ParameterizedType)) {
+ log.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType");
+ return Object.class;
+ }
+
+ Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
+
+ if (index >= params.length || index < 0) {
+ log.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
+ + params.length);
+ return Object.class;
+ }
+ if (!(params[index] instanceof Class)) {
+ log.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
+ return Object.class;
+ }
+
+ return (Class) params[index];
+ }
+
+ /**
+ * 将反射时的checked exception转换为unchecked exception.
+ */
+ public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) {
+ if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
+ || e instanceof NoSuchMethodException) {
+ return new IllegalArgumentException("Reflection Exception.", e);
+ } else if (e instanceof InvocationTargetException) {
+ return new RuntimeException("Reflection Exception.", ((InvocationTargetException) e).getTargetException());
+ } else if (e instanceof RuntimeException) {
+ return (RuntimeException) e;
+ }
+ return new RuntimeException("Unexpected Checked Exception.", e);
+ }
+
+ /**
+ * 根据对象获得mongodb Update语句
+ * 除id字段以外,所有被赋值的字段都会成为修改项
+ */
+ public static Update getUpdateObj(final Object obj) {
+ if (obj == null) {
+ return null;
+ }
+ Field[] fields = obj.getClass().getDeclaredFields();
+ Update update = null;
+ boolean isFirst = true;
+ for (Field field : fields) {
+ field.setAccessible(true);
+ try {
+ Object value = field.get(obj);
+ if (value != null) {
+ if ("id".equals(field.getName().toLowerCase()) || "serialversionuid".equals(field.getName().toLowerCase())) {
+ continue;
+ }
+ if (isFirst) {
+ update = Update.update(field.getName(), value);
+ isFirst = false;
+ } else {
+ update = update.set(field.getName(), value);
+ }
+ }
+
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ return update;
+ }
+}
diff --git a/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/util/StringUtil.java b/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/util/StringUtil.java
new file mode 100644
index 00000000..05212a8d
--- /dev/null
+++ b/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/util/StringUtil.java
@@ -0,0 +1,391 @@
+package vip.mate.core.mongodb.util;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * String工具类
+ *
+ * @author pangu
+ * @date 2020-10-20
+ */
+public class StringUtil {
+
+ private StringUtil() {
+ super();
+ }
+
+ /**
+ * 出去null和""
+ *
+ * @param src
+ * @return
+ */
+ public static String formatNull(String src) {
+ return (src == null || "null".equals(src)) ? "" : src;
+ }
+
+ /**
+ * 判断字符串是否为空的正则表达式,空白字符对应的unicode编码
+ */
+ private static final String EMPTY_REGEX = "[\\s\\u00a0\\u2007\\u202f\\u0009-\\u000d\\u001c-\\u001f]+";
+
+ /**
+ * 验证字符串是否为空
+ *
+ * @param input
+ * @return
+ */
+ public static boolean isEmpty(String input) {
+ return input == null || input.equals("") || input.matches(EMPTY_REGEX);
+ }
+
+ public static boolean isNotEmpty(String input) {
+ return !isEmpty(input);
+ }
+
+ private static final String NUM_REG = "(\\+|\\-)?\\s*\\d+(\\.\\d+)?";
+
+
+ //首字母转小写
+ public static String toLowerCaseFirstOne(String s) {
+ if (Character.isLowerCase(s.charAt(0))) {
+ return s;
+ } else {
+ return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
+ }
+ }
+
+ //首字母转大写
+ public static String toUpperCaseFirstOne(String s) {
+ if (Character.isUpperCase(s.charAt(0))) {
+ return s;
+ } else {
+ return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
+ }
+ }
+
+
+ /**
+ * 判断是否数字
+ *
+ * @param str
+ * @return
+ */
+ public static boolean isNumber(String str) {
+ if (isEmpty(str)) {
+ return false;
+ }
+
+ if (str.trim().matches(NUM_REG)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * 判断是否包含有乱码的数据,如果字符串中包含有替换字符就认为是乱码
+ *
+ * @param str
+ * @return
+ */
+ public static boolean containUnreadableCode(String str) {
+ return contain(str, "\\ufffd");
+ }
+
+ /**
+ * 判读是否包含数字
+ *
+ * @param str
+ * @return
+ */
+ public static boolean containNumber(String str) {
+ return contain(str, "\\d");
+ }
+
+ /**
+ * 判断是否包含a-zA-Z_0-9
+ *
+ * @param str
+ * @return
+ */
+ public static boolean containWord(String str) {
+ return contain(str, "\\w");
+ }
+
+ /**
+ * 是否包含有标点符号
+ *
+ * @param str
+ * @return
+ */
+ public static boolean containPunct(String str) {
+ return contain(str, PUNCT_REG);
+ }
+
+ public static boolean contain(String str, String regex) {
+ if (isEmpty(str) || isEmpty(regex)) {
+ return false;
+ }
+
+ if (str.trim().matches(regex)) {
+ return true;
+ }
+
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(str);
+ if (matcher.find()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * 替换所有的(不区分大小写)
+ *
+ * @param input
+ * @param regex
+ * @param replacement
+ * @return
+ */
+ public static String replaceAll(String input, String regex,
+ String replacement) {
+ return Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(input)
+ .replaceAll(replacement);
+ }
+
+ /**
+ * 移除所有的空格
+ *
+ * @param text
+ * @return
+ */
+ public static String removeAllSpace(String text) {
+ if (isEmpty(text)) {
+ return text;
+ }
+
+ return text.replaceAll("[ ]+", "");
+ }
+
+ private static final String PUNCT_REG = "[^a-zA-Z0-9\\u4e00-\\u9fa5]";
+
+ /**
+ * 移除字符串中的所有的中英文标点符号
+ *
+ * @param str
+ * @return
+ */
+ public static String removeAllPunct(String str) {
+ if (isEmpty(str)) {
+ return str;
+ }
+
+ return str.replaceAll(PUNCT_REG, "");
+ }
+
+ /**
+ * 计算str中包含多少个子字符串sub
+ *
+ * @param str
+ * @param sub
+ * @return
+ */
+ public static int countMatches(String str, String sub) {
+ if (isEmpty(str) || isEmpty(sub)) {
+ return 0;
+ }
+
+ int count = 0;
+ int idx = 0;
+ while ((idx = str.indexOf(sub, idx)) != -1) {
+ count++;
+ idx += sub.length();
+ }
+
+ return count;
+ }
+
+ /**
+ * 获得源字符串的一个子字符串
+ *
+ * @param str :源字符串
+ * @param beginIndex :开始索引(包括)
+ * @param endIndex :结束索引(不包括)
+ * @return
+ */
+ public static String substring(String str, int beginIndex, int endIndex) {
+ if (isEmpty(str)) {
+ return str;
+ }
+
+ int length = str.length();
+
+ if (beginIndex >= length || endIndex <= 0 || beginIndex >= endIndex) {
+ return null;
+ }
+
+ if (beginIndex < 0) {
+ beginIndex = 0;
+ }
+ if (endIndex > length) {
+ endIndex = length;
+ }
+
+ return str.substring(beginIndex, endIndex);
+ }
+
+ /**
+ * 计算str中包含子字符串sub所在位置的前一个字符或者后一个字符和sub所组成的新字符串
+ *
+ * @param str
+ * @param sub
+ * @return
+ */
+ public static Set substring(String str, String sub) {
+ if (isEmpty(str) || isEmpty(sub)) {
+ return null;
+ }
+
+ Set result = new HashSet();
+ int idx = 0;
+ while ((idx = str.indexOf(sub, idx)) != -1) {
+ String temp = substring(str, idx - 1, idx + sub.length());
+ if (!isEmpty(temp)) {
+ temp = removeAllPunct(temp);
+ if (!sub.equalsIgnoreCase(temp) && !containWord(temp)) {
+ result.add(temp);
+ }
+
+ }
+
+ temp = substring(str, idx, idx + sub.length() + 1);
+ if (!isEmpty(temp)) {
+ temp = removeAllPunct(temp);
+ if (!sub.equalsIgnoreCase(temp) && !containWord(temp)) {
+ result.add(temp);
+ }
+ }
+
+ idx += sub.length();
+ }
+
+ return result;
+ }
+
+ /**
+ * 过滤掉XML中无法解析的非法字符
+ *
+ * @param content
+ * @return
+ */
+ public static String wrapXmlContent(String content) {
+ if (isEmpty(content)) {
+ return "";
+ }
+
+ StringBuilder result = new StringBuilder();
+
+ for (int i = 0; i < content.length(); i++) {
+ char ch = content.charAt(i);
+ if ((ch == '\t') || (ch == '\n') || (ch == '\r')
+ || ((ch >= ' ') && (ch <= 55295))
+ || ((ch >= 57344) && (ch <= 65533))
+ || ((ch >= 65536) && (ch <= 1114111))) {
+ result.append(ch);
+ }
+ }
+
+ return result.toString();
+ }
+
+ /**
+ * 判断字符串的长度
+ *
+ * @param str
+ * @return
+ */
+ public static boolean overLength(String str) {
+ if (isEmpty(str)) {
+ return false;
+ }
+
+ return str.length() > 1 ? true : false;
+ }
+
+ /**
+ * 字符串中含有特殊字符的处理
+ *
+ * @param str
+ * @return
+ */
+ public static String specialStr(String str) {
+ str = str.replaceAll("[^\\u4e00-\\u9fa5 | 0-9| a-zA-Z | \\.]+", " ")
+ .replaceAll("[\\.]{2,}", " ").trim();
+ return str;
+ }
+
+ /**
+ * 将特殊符号去掉,但是保留空格
+ *
+ * @param str
+ * @return
+ */
+ public static String replaceInValidateChar(String str) {
+ return str.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5\\s+]", " ");
+ }
+
+ /**
+ * 返回字符串对应的unicode编码
+ *
+ * @param str
+ * @return
+ */
+ public static String[] toHexString(String str) {
+ char[] chars = str.toCharArray();
+
+ String[] result = new String[chars.length];
+
+ for (int i = 0; i < chars.length; i++) {
+ result[i] = Integer.toHexString((int) chars[i]);
+ }
+
+ return result;
+ }
+
+ public static String getUuid() {
+ return UUID.randomUUID().toString();
+ }
+
+ public static boolean isUrl(String src) {
+ String regex = "http[s]?:\\/\\/([\\w-]+\\.[\\w-]+)(\\.[\\w-])+(:\\d{2,10})?.*";
+ Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(src);
+ return matcher.matches();
+ }
+
+ /**
+ * sql 查询转义
+ *
+ * @param str
+ * @return
+ */
+ public static String escapeSql(String str) {
+ if (StringUtil.isNotEmpty(str)) {
+ StringBuffer strbuff = new StringBuffer();
+ for (String s : str.split("")) {
+ if (s.equals("%") || s.equals("_") || s.equals("\\")) {
+ strbuff.append("\\");
+ }
+ strbuff.append(s);
+ }
+ return strbuff.toString();
+ }
+ return str;
+ }
+}
diff --git a/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/vo/Page.java b/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/vo/Page.java
new file mode 100644
index 00000000..7c837a45
--- /dev/null
+++ b/mate-core/mate-starter-mongodb/src/main/java/vip/mate/core/mongodb/vo/Page.java
@@ -0,0 +1,100 @@
+package vip.mate.core.mongodb.vo;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 分页参数实体
+ *
+ * @param
+ * @author pangu
+ * @date 2020-10-20
+ */
+public class Page implements Serializable {
+
+ private static final long serialVersionUID = 5760097915453738435L;
+ public static final int DEFAULT_PAGE_SIZE = 10;
+ /**
+ * 每页显示个数
+ */
+ private int pageSize;
+ /**
+ * 当前页数
+ */
+ private int currentPage;
+ /**
+ * 总页数
+ */
+ private int totalPage;
+ /**
+ * 总记录数
+ */
+ private int totalCount;
+ /**
+ * 结果列表
+ */
+ private List rows;
+
+ public Page() {
+ this.currentPage = 1;
+ this.pageSize = DEFAULT_PAGE_SIZE;
+ }
+
+ public Page(int currentPage, int pageSize) {
+ this.currentPage = currentPage <= 0 ? 1 : currentPage;
+ this.pageSize = pageSize <= 0 ? 1 : pageSize;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public int getCurrentPage() {
+ return currentPage;
+ }
+
+ public void setCurrentPage(int currentPage) {
+ this.currentPage = currentPage;
+ }
+
+ public int getTotalPage() {
+ return totalPage;
+ }
+
+ public void setTotalPage(int totalPage) {
+ this.totalPage = totalPage;
+ }
+
+ public int getTotalCount() {
+ return totalCount;
+ }
+
+ public void setTotalCount(int totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ /**
+ * 设置结果 及总页数
+ *
+ * @param rows
+ */
+ public void build(List rows) {
+ this.setRows(rows);
+ int count = this.getTotalCount();
+ int divisor = count / this.getPageSize();
+ int remainder = count % this.getPageSize();
+ this.setTotalPage(remainder == 0 ? divisor == 0 ? 1 : divisor : divisor + 1);
+ }
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+}
diff --git a/mate-core/mate-starter-oss/pom.xml b/mate-core/mate-starter-oss/pom.xml
index 4d968d0b..d59dd9b1 100644
--- a/mate-core/mate-starter-oss/pom.xml
+++ b/mate-core/mate-starter-oss/pom.xml
@@ -5,7 +5,7 @@
mate-core
vip.mate
- 1.3.8
+ 1.5.8
4.0.0
diff --git a/mate-core/mate-starter-prometheus/pom.xml b/mate-core/mate-starter-prometheus/pom.xml
index f93df5b2..ca69c9e5 100644
--- a/mate-core/mate-starter-prometheus/pom.xml
+++ b/mate-core/mate-starter-prometheus/pom.xml
@@ -5,7 +5,7 @@
mate-core
vip.mate
- 1.3.8
+ 1.5.8
4.0.0
diff --git a/mate-core/mate-starter-redis/pom.xml b/mate-core/mate-starter-redis/pom.xml
index 6b21a162..319ee6a4 100644
--- a/mate-core/mate-starter-redis/pom.xml
+++ b/mate-core/mate-starter-redis/pom.xml
@@ -5,7 +5,7 @@
mate-core
vip.mate
- 1.3.8
+ 1.5.8
4.0.0
diff --git a/mate-core/mate-starter-redis/src/main/java/vip/mate/core/redis/core/RedisService.java b/mate-core/mate-starter-redis/src/main/java/vip/mate/core/redis/core/RedisService.java
index f8feb183..dff1bb14 100644
--- a/mate-core/mate-starter-redis/src/main/java/vip/mate/core/redis/core/RedisService.java
+++ b/mate-core/mate-starter-redis/src/main/java/vip/mate/core/redis/core/RedisService.java
@@ -16,6 +16,7 @@
*/
package vip.mate.core.redis.core;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
@@ -39,6 +40,7 @@
* @author xuzhanfu
* @date 2019-10-11 19:02
**/
+@Slf4j
public class RedisService {
@Autowired
@@ -59,7 +61,7 @@ public Boolean expire(String key, Long time) {
}
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -123,7 +125,7 @@ public Boolean hasKey(String key) {
try {
return redisTemplate.hasKey(key);
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -177,7 +179,7 @@ public Boolean set(String key, Object value) {
redisTemplate.opsForValue().set(key, value);
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -199,7 +201,7 @@ public Boolean set(String key, Object value, Long time) {
}
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -222,7 +224,7 @@ public Boolean set(String key, Object value, Duration timeout) {
}
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -288,7 +290,7 @@ public Boolean hmset(String key, Map map) {
redisTemplate.opsForHash().putAll(key, map);
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -309,7 +311,7 @@ public Boolean hmset(String key, Map map, Long time) {
}
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -327,7 +329,7 @@ public Boolean hset(String key, String item, Object value) {
redisTemplate.opsForHash().put(key, item, value);
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -349,7 +351,7 @@ public Boolean hset(String key, String item, Object value, Long time) {
}
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Exception: {}", e.getMessage());
return false;
}
}
@@ -409,7 +411,7 @@ public Set