按照网上的说法 添加了一个监听器
@Configuration
public class AuthenticationConfiguration implements WebMvcConfigurer {
@Autowired
AuthenticationInterceptor authenticationInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authenticationInterceptor);
WebMvcConfigurer.super.addInterceptors(registry);
}
}
但是实际测试拦截器中redisUtil注入的还是为null,搞不明白了,哪里还有注解没有加么
@Component
public class AuthenticationInterceptor implements HandlerInterceptor {
@Autowired
RedisUtil redisUtil;
启动类
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}