-
懒羊羊
2024-03-27 054a699a156ca607e95f220b364136d42a19ab0f
提交 | 用户 | 时间
caebfa 1 package com.jcdm.main.config;
W 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 }