在SpringCloud中的相关报错

在SpringCloud中使用REST服务时

使用前需要先在配置类中注入RestTemplate的Bean

然后再使用 自动装配即可

    @Autowired
    private RestTemplate restTemplate;

问题一:传递数据为空

调用restTemplate进行数据新增操作,传入 服务提供者那边数据为空,但是在消费者这边有数据
服务消费者:

接收到了前端传入的数据

服务提供者:

接收不到消费者传过来的数据

解决方法:
在服务提供者那边方法上的接收参数 加上@RequestBody 注解 即可解决

SpringBoot和SpringCloud版本不匹配

如果出现Error creating bean with name 'traceFilterRegistration' 的报错,说明我们引入的SpringBoot和SpringCloud的依赖不匹配,可以去官网查看匹配的依赖包

Spring Cloud 官网

Spring Boot 官网

posted @ 2023-01-05 18:28  没有烦恼的猫猫  阅读(40)  评论(0)    收藏  举报