当前位置:网站首页>fegin feign.FeignException: status 404 reading StudenService#getAll()
fegin feign.FeignException: status 404 reading StudenService#getAll()
2022-08-06 05:03:00 【luguz】
最近复习springcloud的fegin时调用服务出现错误
feign.FeignException: status 404 reading StudenService#getAll()
意思是找不到这个服务下的getAll方法,先打断点查看fegin的服务是否注册进来了
根据debug的信息可以发现服务是成功注册进来了,再查看fegin的方法跟provide的方法是否有区别
发现是getALl方法名字错误,将名字对应起来重新启动,发现还是不能正确加载,测试发现还是映射的问题,将
@Component
@FeignClient("SPRINGCLOUD-PROVIDE") //配置微服务的名字 要提供给哪个既注册在微服务中心的服务名
@RequestMapping("/student")
public interface StudenService {
@GetMapping("/getAll")
List<Student> getAll();
}
改为
@Component
@FeignClient("SPRINGCLOUD-PROVIDE") //配置微服务的名字 要提供给哪个既注册在微服务中心的服务名
public interface StudenService {
@GetMapping("/student/getAll")
List<Student> getAll();
}
即可正常访问,判断是@RequestMapping跟@FeignClient可能发生冲突,查找资料发现另外如果@FeignClient跟@RequestMapping同时存在的话要添加一个配置类过滤掉有@FeignClient注解的类,添加一个FeignConfiguration配置即可正常访问
package springcloud.config;
import feign.Feign;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
/** * @author Guz * @create 2022-07--27 11:03 */
@Configuration
@ConditionalOnClass({
Feign.class})
public class FeignConfiguration {
@Bean
public WebMvcRegistrations feignWebRegistrations() {
return new WebMvcRegistrations() {
@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
return new FeignRequestMappingHandlerMapping();
}
};
}
/** * swagger过滤同时被 @FeignClient和@RequestMapping 修饰的类 */
private static class FeignRequestMappingHandlerMapping extends RequestMappingHandlerMapping {
@Override
protected boolean isHandler(Class<?> beanType) {
return super.isHandler(beanType) &&
!AnnotatedElementUtils.hasAnnotation(beanType, FeignClient.class);
}
}
}
边栏推荐
- 响应式织梦模板企业集团类网站
- 数学建模学习(77):matlab相关性分析(皮尔逊,肯德尔,斯皮尔曼)
- 数学建模学习(78):多输入多输出回归预测模型(结合XGBoost实现)
- 工业机器人模拟题
- Practical debugging tips
- 想完全掌握Swagger,这一篇就够了!
- 温度敏感/PH敏感/电场敏感/温度/pH双重敏感/磁场敏感型水凝胶的制备
- egg框架的使用
- 2022 Practical Content Course on Building Modern Web Applications with Go
- 数据库系统原理与应用教程(079)—— MySQL 练习题:操作题 181-185(二十三):综合练习
猜你喜欢

Romantic Tanabata - lucky to have you all the way

YGG 与《元素突击》的创造者游戏平台 G4AL 达成合作

【Image classification】2021-CvT

解决错误:DispatcherServlet爆红!!

Datax and Datax-web download and use

金属材料/多肽/多糖/化合物/抗体/量子点/黑磷量子点修饰水凝胶

Jhipster介绍和使用

【D1 Dock Pro开发板】LED灯闪烁

js implements that the array is divided into a new array of groups of 5 objects

数学建模学习(78):多输入多输出回归预测模型(结合XGBoost实现)
随机推荐
解决错误:DispatcherServlet爆红!!
Clion sets toolchains error
[C language array subscript out of bounds] Infinite loop caused by array subscript out of bounds
字节跳动 Flink 状态查询实践与优化
浪漫七夕—很幸运一路有你
Romantic Tanabata - lucky to have you all the way
响应式织梦模板潜水游泳类网站
Share an easy-to-use ad-free mobile browser, it is worth downloading for pro test
1×1 问题详解
623. 在二叉树中增加一行
【D1 Dock Pro开发板】LED灯闪烁
Flink-cdc 同步mysql数据
Develop a SQL editor with Monaco Editor
重发布中的路由策略:
牛刀小试基本语法,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang基本语法和变量的使用EP02
aws篇7
工业机器人模拟题
egg框架的使用
Base64与16进制HEX之间的转换
如何设置跨域隔离启用 SharedArrayBuffer