在orderservice子工程中
<!--feign的远程-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
启动类加上这个注解
@EnableFeignClients //自动装配的开关
@MapperScan("cn.itcast.order.mapper")
@SpringBootApplication
@EnableFeignClients //自动装配的开关
public class OrderApplication {
public static void main(String[] args) {
SpringApplication.run(OrderApplication.class, args);
}
}
在orderservice中华编写接口加上调用服务的名称@FeignClient(“userservice”) 调用userservice
@FeignClient("userservice")
public interface UserClient {
@GetMapping("/user/{id}")
User findById(@PathVariable("id") Long id);
}

@Service
public class OrderService {
@Autowired
private OrderMapper orderMapper;
@Autowired
private UserClient userClient;
public Order queryOrderById(Long orderId) {
// 1.查询订单
Order order = orderMapper.findById(orderId);
User user= userClient.findById(order.getUserId());
order.setUser(user);
System.out.println(user);
// 4.返回
return order;
}
}












![[AutoSar]BSW_Diagnostic_004 ReadDataByIdentifier(0x22)的配置和实现](https://img-blog.csdnimg.cn/direct/c84c73a2eab942bba8aeefddae9f851d.png)


![[Java EE] 文件IO(一):文件概念与文件系统操作](https://img-blog.csdnimg.cn/direct/c539adac66b24eaba226cef372cfd33d.png)



![【Linux】- Linux环境变量[8]](https://img-blog.csdnimg.cn/direct/6dfd796f568a44e58aed70d22731b5e0.png)