v1.27.1 beta. 细节优化

This commit is contained in:
click33
2021-10-19 20:43:13 +08:00
parent 82591e397f
commit f9ec6e6487
5 changed files with 19 additions and 7 deletions

View File

@@ -35,6 +35,7 @@
<version>2.11.2</version>
<optional>true</optional>
</dependency>
<!-- jackson-datatype-jsr310 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>

View File

@@ -55,14 +55,16 @@ public class SaTokenDaoRedisJackson implements SaTokenDao {
// 指定相应的序列化方案
StringRedisSerializer keySerializer = new StringRedisSerializer();
GenericJackson2JsonRedisSerializer valueSerializer = new GenericJackson2JsonRedisSerializer();
// 通过反射获取Mapper对象, 配置[忽略未知字段], 增强兼容性
// 通过反射获取Mapper对象, 增加一些配置, 增强兼容性
try {
Field field = GenericJackson2JsonRedisSerializer.class.getDeclaredField("mapper");
field.setAccessible(true);
ObjectMapper objectMapper = (ObjectMapper) field.get(valueSerializer);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.registerModule(new JavaTimeModule());
this.objectMapper = objectMapper;
// 配置[忽略未知字段]
this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 配置[时间类型转换]
this.objectMapper.registerModule(new JavaTimeModule());
} catch (Exception e) {
System.err.println(e.getMessage());
}

View File

@@ -97,7 +97,7 @@ public class StpLogicJwtForStateless extends StpLogic {
String tokenValue = SaJwtUtil.createToken(
loginType,
id,
loginModel.getDeviceOrDefalut(),
loginModel.getDeviceOrDefault(),
loginModel.getTimeout(),
jwtSecretKey()
);