(三)SpringCloud入门篇——微服务消费者订单Module模块
目录

建cloud-consumer-order80
改POM
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
写YML

主启动

业务类
客户端消费者80 要调 微服务提供者8001,客户端应该只有controller。
entity
先去复制实体类,后面会抽取。

Resttemplate
是什么

官方使用
config配置类
ApplicationContextConfig

controller
测试
启动两个服务

http://localhost/consumer/payment/get/2

不要忘记@RequestBody注解
输入:http://localhost/consumer/payment/create?serial=111
浏览器显示插入成功

但是数据库有主键,serial为null

原因:
没有加@RequestBody注解


浙公网安备 33010602011771号