xxl-job 分布式job调度中心接入参考地址:https://blog.csdn.net/lich1n/article/details/81407400
问题1:
集成后可能出现RestTemplate未定义的错误,如:
Consider defining a bean of type 'org.springframework.web.client.RestTemplate' in your configuration.
或:
No qualifying bean of type [org.springframework.web.client.RestTemplate] found
解决方案:
简单地定义一个@Bean:
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
原因:
和框架版本相关
Spring Boot<=1.3 无需定义,Spring Boot自动为您定义了一个;
Spring Boot >= 1.4 Spring Boot不再自动定义一个RestTemplate
,而是定义了一个RestTemplateBuilder
允许您更好地控制所RestTemplate
创建的对象
@Autowired private RestTemplate restTemplate;
或
@Inject private RestTemplate restTemplate;