1、
@Configuration public class RedisTokenStoreConfig { @Autowired private RedisConnectionFactory redisConnectionFactory; @Bean public TokenStore redisTokenStore(){ RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory); redisTokenStore.setPrefix("xxx"); return redisTokenStore; } }
2、
@Configuration @EnableAuthorizationServer public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Autowired TokenStore redisTokenStore;
问题: redisTokenStore 注入为空
解决方法:
1、
@Resource
TokenStore redisTokenStore;
2、redisTokenStore() 迁到 AuthorizationServerConfig 内
@Bean RedisTokenStore redisTokenStore(){ return new RedisTokenStore(redisConnectionFactory); }