当前位置: 首页 > news >正文

分布式架构demo

1、外层创建pom

版本管理器

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.7.15</version><relativePath/> <!-- lookup parent from repository -->
</parent>

服务间调用 untitled1 调用 untitled2

  

 启动。。。。

untitled1   主要代码

@SpringBootApplication
public class Untitled1 {public static void main(String[] args) {SpringApplication.run(Untitled1.class,args);System.out.println("Hello world!");}@Beanpublic RestTemplate restTemplate(RestTemplateBuilder builder){//官网建议构造器 构建一个builder 使用构造着设计模式 可是设置请求时间啥的RestTemplate restTemplate = builder.build();return  restTemplate;}
}

Controller 代码    

@RestController
@RequestMapping("/order")
public class Demo1Controller {@AutowiredRestTemplate restTemplate;@PostMapping("/login")public String loging(){String msg= restTemplate.getForObject("http://localhost:8082/stock/reduct",String.class);return  "order"+msg;}}

untitled2  Controller 代码

@RestController
@RequestMapping("/stock")
public class Demo1Controller {@GetMapping("/reduct")public String loging(){return  "扣减库存";}}
http://www.lryc.cn/news/252044.html

相关文章:

  • TA-Lib学习研究笔记(二)——Overlap Studies上
  • 牛客java基础考点1 标识符和变量
  • Qt将打印信息输出到文件
  • 【risc-v】易灵思efinix FPGA sapphire_soc IP配置参数分享
  • 直播的种类及类型
  • 时间序列数据压缩算法简述
  • 智能锁-SI522TORC522方案资料
  • redux(4) -RTK简单使用
  • 开源运维监控系统-Nightingale(夜莺)应用实践(未完)
  • 深入理解GMP模型
  • 数学建模-基于集成学习的共享单车异常检测的研究
  • C语言-内存分配
  • 算法工程师-机器学习面试题总结(1)
  • 【蓝桥杯选拔赛真题73】Scratch烟花特效 少儿编程scratch图形化编程 蓝桥杯创意编程选拔赛真题解析
  • Juniper EX系列交换机端口配置操作
  • 2.1 Linux C 编程
  • 服务器数据恢复—ocfs2文件系统被格式化为其他文件系统如何恢复数据?
  • 海云安参与制定《信息安全技术 移动互联网应用程序(App)软件开发工具包(SDK)安全要求》标准正式发布
  • 如何调用 API | 学习笔记
  • 关于云备份项目的HTTP协议字段理解
  • 掉落的俄罗斯方块
  • 医院不良事件报告系统源码带鱼骨图分析
  • 数据库相关算法题 V3
  • 第二证券:本周3只新股申购,大豆蛋白行业领军企业来了!
  • 【go语言开发】loglus日志框架的使用
  • 【Unity动画】Unity 动画播放的流程
  • 深度学习——第3章 Python程序设计语言(3.2 Python程序流程控制)
  • EasyExcel生成多sheet页的excel
  • 家用小型洗衣机哪款性价比高?内衣洗衣机品牌推荐
  • 为何Go爬虫依然远没有Python爬虫流行