1、在消费者中注册RestTemplate(基于RestTemplate发起的http请求实现远程调用)
在标注@Configuration配置类中添加@Bean,也可以在@SpringBootApplication中
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
2、在服务调用区注入
例:
@Service
public
1、在消费者中注册RestTemplate(基于RestTemplate发起的http请求实现远程调用)
在标注@Configuration配置类中添加@Bean,也可以在@SpringBootApplication中
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
2、在服务调用区注入
例:
@Service
public