diff --git a/pig-common/pom.xml b/pig-common/pom.xml
index a15ceb82..b1e086c3 100644
--- a/pig-common/pom.xml
+++ b/pig-common/pom.xml
@@ -90,6 +90,13 @@
fastdfs-spring-boot-starter
${fastdfs.version}
+
+
+ com.alibaba
+ transmittable-thread-local
+ ${ttl.version}
+
+
diff --git a/pig-common/src/main/java/com/github/pig/common/util/UserUtils.java b/pig-common/src/main/java/com/github/pig/common/util/UserUtils.java
index e28f6321..c6d546e1 100644
--- a/pig-common/src/main/java/com/github/pig/common/util/UserUtils.java
+++ b/pig-common/src/main/java/com/github/pig/common/util/UserUtils.java
@@ -1,8 +1,10 @@
package com.github.pig.common.util;
+import com.alibaba.ttl.TransmittableThreadLocal;
import com.github.pig.common.constant.CommonConstant;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,9 +19,9 @@ import java.util.List;
* @date 2017/11/20
* 用户相关工具类
*/
+@Slf4j
public class UserUtils {
- private static Logger logger = LoggerFactory.getLogger(UserUtils.class);
- private static final ThreadLocal THREAD_LOCAL_USER = new ThreadLocal<>();
+ private static final ThreadLocal THREAD_LOCAL_USER = new TransmittableThreadLocal<>();
private static final String KEY_USER = "user";
@@ -44,7 +46,7 @@ public class UserUtils {
Claims claims = Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody();
username = claims.get("user_name").toString();
} catch (Exception ex) {
- logger.error("用户名解析异常,token:{},key:{}", token, key);
+ log.error("用户名解析异常,token:{},key:{}", token, key);
}
return username;
}
@@ -66,7 +68,7 @@ public class UserUtils {
Claims claims = Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody();
username = claims.get("user_name").toString();
} catch (Exception ex) {
- logger.error("用户名解析异常,token:{},key:{}", token, key);
+ log.error("用户名解析异常,token:{},key:{}", token, key);
}
return username;
}
diff --git a/pom.xml b/pom.xml
index 1787631a..17f1ff4d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,7 @@
5.4.1.Final
2.8.0
0.2.0
+ 2.2.0
2.0.1
2.0
[7.2.0, 7.2.99]