admin
2024-07-05 50c5856086b9302fb8a8ecfe3db7e32a35c2ccff
提交 | 用户 | 时间
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 }