cl
2024-07-04 5b544fc8d6029a71669b3992c5cfea9a044aaf3f
提交 | 用户 | 时间
0ca254 1 package com.jcdm.main.config;
A 2
3 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
4 import org.springframework.context.annotation.Bean;
5 import org.springframework.context.annotation.Configuration;
6 import org.springframework.web.client.RestTemplate;
7
8 @Configuration
9 public class RestTemplateConfig {
10     /**
11      * 没有实例化RestTemplate时,初始化RestTemplate
12      * @return
13      */
14     @ConditionalOnMissingBean(RestTemplate.class)
15     @Bean
16     public RestTemplate restTemplate(){
17         RestTemplate restTemplate = new RestTemplate();
18         return restTemplate;
19     }
20
21
22 }