微服务远程调用

55 阅读1分钟

 

 步骤 1:注册RestTemplate

在order-service的OrderApplication中注册RestTemplate

@SpringBootApplication
public class SquareApplication {
    public static void main(String[] args) {
        SpringApplication.run(SquareApplication.class,args);
    }

    /**
     * 创建RestTemplate 并注入Spring容器
     * @return
     */
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}