[Microservice Study Notes] Understanding Microservices
monolithic architecture
distributed architecture
microservice architecture
SpringCloud
Service Splitting and Considerations
Case demo of service splitting
The databases of each service are independent of each other. You cannot directly access the database of the other party, and you can only initiate remote calls from one service to another.
Initiate a request for user query in the service of the order module
Register the RestTemplate in the entry class in the Order-Service module and use it to send http requests
In the page for querying orders, inject the restTemplate variable, and then use it to send http requests to query users
public Order queryOrderById(Long orderId) {
// 1.查询订单
Order order = orderMapper.findById(orderId);
// 创建url
String url = "http://localhost:8081/user/" + order.getUserId();
// 发哦是那个http请求 实现远程调用
User user = restTemplate.getForObject(url,User.class);
// 封装user到Order
order.setUser(user);
// 返回user
return order;
// 4.返回
// return order;
}