hdy
2025-02-27 bf5dcc46de28c2ca664be4c6c3566e0a82c1ecd6
提交 | 用户 | 时间
bf5dcc 1 package com.billion.main.config;
H 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 }