HandlerInterceptor injection bean reported an error.

  springboot

Error reporting configuration

@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new DemoInterceptor());
    }
}

Ok configuration

@Component
public class DemoInterceptor implements HandlerInterceptor {
     
}
@Configuration
public class InterceptorCongif extends WebMvcConfigurerAdapter {

    @Autowired
    DemoInterceptor demoInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(demoInterceptor);
    }
}

doc