Solve the interceptor calling service layer to display null pointer.

When springBoot lets the interceptor, the interceptor object does not use the New interceptor object, but instead USES bean injection.


@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {

    @Autowired
    private AuthorizationInterceptor authorizationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**");

    }

}


 

Read More: