两个服务器端口号和ip地址不一样这点就不用说了啊。

1、需要用到RestTemplate这个类,首先先在启动类注入此Bean

一台服务器如何调另一台服务器里的接口(服务)

@Bean
public RestTemplate restTemplate() {
    return new RestTemplate();
}

2、在业务逻辑部分进行服务的调用,与事务是否控制无关,我只是用到了事务

一台服务器如何调另一台服务器里的接口(服务)

restTemplate.getForObject("http://192.168.137.132:8080/item/queryItemByItemId/" + itemid, Item.class);

这样基本就可以了 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
  • 2021-09-26
  • 2021-12-16
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2021-12-09
  • 2021-04-08
相关资源
相似解决方案