这个只需修改一个地方就可以了,在接口的注解上一个produces =MediaType.APPLICATION_PROBLEM_JSON_VALUE即可

    @RequestMapping(value = "save",produces =MediaType.APPLICATION_PROBLEM_JSON_VALUE)
    public  Map<String,String> save(Integer id){
        Map<String,String> result=new HashMap<>();
        ResponseEntity<Product> response = restTemplate.getForEntity("http://product-service/api/product/findById?id=" + id, Product.class);
        System.out.println(response);

        result.put("code","1");
        result.put("data","success");
        result.put("message","订单提交成功");
        result.put("product_name","");
        return result;
    }

我看了一个别人写过的blog,他说需要添加其他jar包在pom文件中,但是我没有加就可以了,不过处理这个问题是受他的启发,

所以这里贴一下这个兄台的链接,如果想看的话可以点击查看一下

https://blog.csdn.net/Hmily_hui/article/details/82994868

 

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐