spring-cloud-openfeign
spring-cloud-openfeign copied to clipboard
【help】why throw new IllegalArgumentException("@RequestMapping annotation not allowed on @FeignClient interfaces");
why version3.0.5 begin throw new IllegalArgumentException("@RequestMapping annotation not allowed on @FeignClient interfaces");
protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
RequestMapping classAnnotation = findMergedAnnotation(clz, RequestMapping.class);
if (classAnnotation != null) {
LOG.error("Cannot process class: " + clz.getName()
+ ". @RequestMapping annotation is not allowed on @FeignClient interfaces.");
throw new IllegalArgumentException("@RequestMapping annotation not allowed on @FeignClient interfaces");
}
}
https://github.com/shinestmt/webmvc-rpc-starter.git
like this:
webmvc-rpc-spring-boot-starter-client # RequestMappingFeignClientSpringMvcContract
I just updated an application and did run into the same issue. I have an application that exposes an API and I'm using tests that create a feign client with FeignBuilder and uses the same class that is exposed for testing. This does not work anymore, that's quite sad.
Also, I don't understand this change. I don't want Feign annotations in my API so now this client is useless to me.
Agree with the above, it makes the client useless to me as well.
Also, I have the same issue. Is this change really necessary?
I have the same problem... 🔥🤬
Also , i have the same problem. What was the reason of this change ?
Also , i have the same problem. What was the reason of this change ? See here: https://github.com/spring-cloud/spring-cloud-netflix/issues/466
I have the same problem.
it make it difficult to let the controller implement the feignclient interface. eg. ` @FeignClient("path=test") public interface TestClient { }
@RestController public class TestController implements TestClient } `
now the TestController need to adds a @RequestMapping("test") to make it work.
Also , i have the same problem. What was the reason of this change ?
And now with version 6.2.0
of openapi-generator - my project has started failing because they added @RequestMapping
in the api.mustache
file for the JavaSpring
module.
I currently work around this by using a custom api.mustache
template file with the RequestMapping removed.
It would be beneficial for both openapi-generator and spring-cloud-openfeign project to get on the same page so they can work together.
The below was true, but I was generating the code via openapi incorrectly. If setup properly for my use-case, openapi does not generate @RequestMapping on the interface and I can use a feign client for testing just fine. Just wanted to point out that openfeign works fine with output from openapi, if its configured appropriately.
Same issue as other folks. I'm generating my API interface with openapi, then it's implemented in Spring (pure Spring, not spring-boot). In my integration tests, I build a Feign client to call the server - but it fails with this message.
mark,i have the same problem
Hello, @letian-tang, this was done on purpose (see https://tanzu.vmware.com/security/cve-2021-22044 and https://github.com/spring-cloud/spring-cloud-openfeign/issues/547). It was always discouraged as a bad practice in the docs. Since it also caused a security issue, the team has decided to remove it. Closing as duplicate of gh-678.