xml
复制代码
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-reactor-spring-boot3-starter</artifactId>
</dependency>
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-redis-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
启动类增加注解
java
复制代码
@EnableAspectJAutoProxy
java
复制代码
package com.ys.config;
import com.alibaba.fastjson2.JSON;
import com.ys.constant.RedisConstant;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
* @author kong
*/
@Aspect
@Component
@Slf4j
public class SaTokenDaoRedisJacksonAspect {
// 定义切点,匹配SomeClass类的所有方法
@Pointcut("execution(* cn.dev33.satoken.dao.SaTokenDaoRedisJackson.*(..))")
public void methodPointcut() {
}
// 在方法执行前执行的操作
@Around("methodPointcut()")
public Object beforeMethod(ProceedingJoinPoint joinPoint) throws Throwable {
Object[] args = joinPoint.getArgs();
for (int i = 0, n = args.length; i < n; i++) {
if (args[i] instanceof String temp) {
if (temp.contains("token")) {
args[i] = RedisConstant.PREFIX + temp;
}
}
}
return joinPoint.proceed(args);
}
}