feat: 为 SaTokenPluginForJackson 指定较弱的优先级

This commit is contained in:
click33 2025-03-19 04:34:47 +08:00
parent b25fc289da
commit fb95acc8ce
3 changed files with 7 additions and 3 deletions

View File

@ -33,7 +33,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- Sa-Token 权限认证, 在线文档https://sa-token.cc/ -->
<dependency>
<groupId>cn.dev33</groupId>

View File

@ -16,6 +16,7 @@
package cn.dev33.satoken.plugin;
import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.json.SaJsonTemplateDefaultImpl;
import cn.dev33.satoken.json.SaJsonTemplateForJackson;
/**
@ -28,7 +29,10 @@ public class SaTokenPluginForJackson implements SaTokenPlugin {
@Override
public void install() {
SaManager.setSaJsonTemplate(new SaJsonTemplateForJackson());
// 只有在未提供自定义的 json 解析器时才会生效给于其较弱的优先级
if(SaManager.getSaJsonTemplate().getClass() == SaJsonTemplateDefaultImpl.class){
SaManager.setSaJsonTemplate(new SaJsonTemplateForJackson());
}
}
}

View File

@ -43,7 +43,7 @@
<optional>true</optional>
</dependency>
<!-- jackson 序列化、redis集成、SSO、OAuth2 等模块要用到 -->
<!-- jackson 序列化、redis集成、SSO、OAuth2 等模块要用到,比较重要所以内置集成 -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-jackson</artifactId>