RestTemplate方式调用存在的问题
-
- String url="http://userservice/user/"+order.getUserId();
- User user = restTemplate.getForObject(url, User.class);
①引入依赖
-
-
-
org.springframework.cloud -
spring-cloud-starter-openfeign -
②主启动类上加上@EnableFeignClients注解开启Feign的功能
-
- @MapperScan("cn.itcast.order.mapper")
- @SpringBootApplication
- @EnableFeignClients
- public class OrderApplicatio