记录微服务nacos中使用Feign 报feign.FeignException: status 404 reading

这篇文章只是笔者做的一个BUG解决记录,每个人遇到的问题来源可能不同,参考价值不大。
今天在学习feign服务调用时,配置完以后启动spring boot,结果报错,报错内容显示找不到getByProduct这个方法 O(U_U)O,先来看看项目内容:

记录微服务nacos中使用Feign 报feign.FeignException: status 404 reading

order方代码

package com.xiao.service.feignservice;

import com.xiao.model.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@FeignClient(value = "service-product")
public interface ProductService {
    @GetMapping(value = "/id/{id}")
    Product getByProduct(@PathVariable Integer id);
}

product方代码

记录微服务nacos中使用Feign 报feign.FeignException: status 404 reading

最后发现,原来在调用时,要把requestMapping 地址写全如:

@FeignClient(value = "service-product")
public interface ProductService {
    @GetMapping(value = "/product/id/{id}") ## 这个地方
    Product getByProduct(@PathVariable Integer id);
}
本作品采用《CC 协议》,转载必须注明作者和本文链接
MissYou-Coding
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
Coding Peasant @ 互联网
文章
193
粉丝
10
喜欢
60
收藏
63
排名:602
访问:1.3 万
私信
所有博文
博客标签
社区赞助商