修复 sa-token-alone-redis + sa-token-dao-redis-fastson 时 Redis 无法分离的问题

This commit is contained in:
click33 2022-10-20 06:41:35 +08:00
parent 6b9901499a
commit aa22fe84ee
4 changed files with 36 additions and 4 deletions

View File

@ -29,6 +29,18 @@
<artifactId>sa-token-dao-redis-jackson</artifactId>
<version>${revision}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-dao-redis-fastjson</artifactId>
<version>${revision}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-dao-redis-fastjson2</artifactId>
<version>${revision}</version>
<optional>true</optional>
</dependency>
<!-- redis pool -->
<dependency>

View File

@ -18,6 +18,8 @@ import org.springframework.data.redis.connection.lettuce.LettucePoolingClientCon
import cn.dev33.satoken.dao.SaTokenDao;
import cn.dev33.satoken.dao.SaTokenDaoDefaultImpl;
import cn.dev33.satoken.dao.SaTokenDaoRedis;
import cn.dev33.satoken.dao.SaTokenDaoRedisFastjson;
import cn.dev33.satoken.dao.SaTokenDaoRedisFastjson2;
import cn.dev33.satoken.dao.SaTokenDaoRedisJackson;
/**
@ -95,7 +97,7 @@ public class SaAloneRedisInject implements EnvironmentAware{
factory.afterPropertiesSet();
// 3. 开始初始化 SaTokenDao
// 如果是SaTokenDaoRedis
// 如果开发者引入的是sa-token-dao-redis
try {
Class.forName("cn.dev33.satoken.dao.SaTokenDaoRedis");
SaTokenDaoRedis dao = (SaTokenDaoRedis)saTokenDao;
@ -104,7 +106,7 @@ public class SaAloneRedisInject implements EnvironmentAware{
return;
} catch (ClassNotFoundException e) {
}
// 如果是SaTokenDaoRedisJackson
// 如果开发者引入的是sa-token-dao-redis-jackson
try {
Class.forName("cn.dev33.satoken.dao.SaTokenDaoRedisJackson");
SaTokenDaoRedisJackson dao = (SaTokenDaoRedisJackson)saTokenDao;
@ -113,6 +115,24 @@ public class SaAloneRedisInject implements EnvironmentAware{
return;
} catch (ClassNotFoundException e) {
}
// 如果开发者引入的是sa-token-dao-redis-fastjson
try {
Class.forName("cn.dev33.satoken.dao.SaTokenDaoRedisFastjson");
SaTokenDaoRedisFastjson dao = (SaTokenDaoRedisFastjson)saTokenDao;
dao.isInit = false;
dao.init(factory);
return;
} catch (ClassNotFoundException e) {
}
// 如果开发者引入的是sa-token-dao-redis-fastjson2
try {
Class.forName("cn.dev33.satoken.dao.SaTokenDaoRedisFastjson2");
SaTokenDaoRedisFastjson2 dao = (SaTokenDaoRedisFastjson2)saTokenDao;
dao.isInit = false;
dao.init(factory);
return;
} catch (ClassNotFoundException e) {
}
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -18,7 +18,7 @@ import cn.dev33.satoken.strategy.SaStrategy;
import cn.dev33.satoken.util.SaFoxUtil;
/**
* Sa-Token持久层接口 [Redis版 (使用JSON字符串进行序列化)]
* Sa-Token 持久层实现 [Redis存储fastjson序列化]
*
* @author sikadai
*

View File

@ -18,7 +18,7 @@ import cn.dev33.satoken.strategy.SaStrategy;
import cn.dev33.satoken.util.SaFoxUtil;
/**
* Sa-Token持久层接口 [Redis版 (使用JSON字符串进行序列化)]
* Sa-Token 持久层实现 [Redis存储fastjson2序列化]
*
* @author sikadai
*