@RequestMapping annotation not allowed on @FeignClient interfaces

来源:2-14 【技术改造】电商系统用户模块集成Feign-1

网信科技

2022-06-01 17:49:40

service模块,@RequestMapping 与 @FeignClient 一起使用是报错

相关代码:

@FeignClient("foodie-item-service")
@RequestMapping("item-comments-api")

public interface ItemCommentsService {
    ....
}

// 启动报错
Unexpected exception during bean creation; nested exception is 
java.lang.IllegalArgumentException: 
@RequestMapping annotation not allowed on @FeignClient interfaces


我在网上搜索了一下,他们说两个注解不能一起使用。会不会和springboot版本有关?我的环境 springboot 2.6.8  springcloud 2021.0.2

写回答

1回答

姚半仙

2022-06-03

同学说的没错,所以在新版本里面,我们就把requestmapping里的路径参数放到GetMapping/PostMapping这类方法注解上就可以了

0

Java架构师-技术专家

千万级电商项目从0到100全过程,覆盖Java程序员不同成长阶段的核心问题与解决方案

2672 学习 · 5839 问题

查看课程

相似问题

回答 1

回答 1

回答 2

回答 1