@
yanghanlin 这样就行了!!感谢!!!
```java
@
Componentpublic class RestTemplateUtil implements ApplicationListener<ApplicationStartedEvent>, ApplicationContextAware {
private static RestTemplate REST_TEMPLATE;
private ApplicationContext applicationContext;
private RestTemplateUtil() {
}
public void setApplicationContext(ApplicationContext inputApplicationContext) throws BeansException {
this.applicationContext = inputApplicationContext;
}
public void onApplicationEvent(ApplicationStartedEvent event) {
RestTemplate restTemplate = (RestTemplate)this.applicationContext.getBean("xuegao-framework-restTemplate", RestTemplate.class);
setRestTemplate(restTemplate);
log.info("[xue-gao-framework][RestTemplateUtil][onApplicationEvent][设置 restTemplate 完毕]");
}
public static void setRestTemplate(RestTemplate restTemplate) {
if (REST_TEMPLATE == null) {
REST_TEMPLATE = restTemplate;
}
}
```