I have a Spring MVC application. Below is one class that has RestTemplate and calling external service, it's working fine.
We migrated Spring MVC (war) to Spring Boot 1.5.7 (jar). With migration, below is giving NullPointerException for restTemplate. I have added a print statement and restTemplate is null.
I have added @Bean with getRestTemplate(), but that's still giving same error.
@Service
Class Impl{
@Autowired
private RestTemplate restTemplate;
public RestTemplate getRestTemplate() {
return restTemplate;
}
public void setRestTemplate(final RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
}
How do I fix this ? Why is it working with Spring MVC and not with Spring Boot?