I would like to provide more clearance to your case
first as Cranic Cai pointed out that you should annotate you BaseConfig class with @Configuration annotation so that the spring will pickup and instantiate the object and injected it in Spring Context so you can @Autowired it in all other Spring Context object related.
second if you already directly instantiate a new object in the bean definition like this
@Bean
@Primary
RestTemplate restTemplate(@Autowired RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder.errorHandler(
new IPSRestErrorHandler() -> this is a new object will not be autowired from Spring Context
).build();
}
}
it will not be autowired from your defined class component because you instantiate a new object here. if this is what you want then you can remove completely the @Component annotation from IPSRestErrorHandler class
public class IPSRestErrorHandler extends DefaultResponseErrorHandler { ... }