consumer调用order服务,首先在consumer中填写配置类@Configuration @Bean/ public RestTemplate getRestTemplate(){ return new RestTemplate();} 将RestTemplate注入bean
然后controller中通过RestTemplate的实例化对象通过postForObject和getForObject调用order服务
注意点RestTemplate postForObject有3个重载方法有URL和string的形参,使用时注意以免报错,如果定义了string=“url”的形式应该用string开头的形参。如果用url开头的形参会报错