pom文件引入redis和commons-pool2<!--redis 依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!--commons-pool2 对象池依赖--> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </dependency>
application.properties文件
#Redis配置 spring.redis.host=127.0.0.1
添加 RedisConfig 类
/** * Redis配置 * @auther lql * @create 2022-05-28 10:10 **/ @Configuration public class RedisConfig { @Autowired private RedisConnectionFactory redisConnectionFactory; @Bean public TokenStore redisTokenStore(){ return new RedisTokenStore(redisConnectionFactory); } }
AuthorizationServerConfig类@Autowired @Qualifier("redisTokenStore") private TokenStore tokenStore;