java.lang.IllegalStateException: Method get not annotated with HTTP method type (ex. GET, POST);
明明指定了请求方法类型还报错:
代码:
@RequestMapping(value="/enterprise/detail",method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseMsg get(@RequestBody RequestMsg req);
异常信息:
java.lang.IllegalStateException: Method get not annotated with HTTP method type (ex. GET, POST);
网上好多这个异常的是加POST GET方法。但我这个是加了的。为什么呢?这个时候就要想底层的契约了。
Fegin配置文件是这样的:
@Configuration
public class FeignClientUserServiceConfiguration {
@Bean
Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
} @Bean
public Contract feignContract() {
return new feign.Contract.Default();
} @Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor("user", "password");
}
}
红色部分显示项目用的是fegin的契约。
默认契约用的是@RequestLine注解。RequestLine 如果不知名POST还是GET 就会报 Method get not annotated with HTTP method type (ex. GET, POST)。
那如果要用@RequestMapping 注解怎么办呢,把上面的红色部分的配置删掉,那样Fegin会使用SpringMvcContract契约。问题就解决了。
java.lang.IllegalStateException: Method get not annotated with HTTP method type (ex. GET, POST);的更多相关文章
- springboot 启动报错 java.lang.IllegalStateException: Failed to introspect annotated methods on class org
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ...
- Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)
使用Mediaplayer播放本地音频,在第二次调用mediaplayer.setDataSource()时报错如下: Caused by: java.lang.IllegalStateExcepti ...
- AOP拦截日志类,抛异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode
AOP的日志拦截类中,抛出异常: java.lang.IllegalStateException: It is illegal to call this method if the current r ...
- 异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/userInfoMaint/getProvince.do'
调试代码时出现异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/user ...
- Feign调用远程服务报错:Caused by: java.lang.IllegalStateException: Method getMemberInfo not annotated with HTTP method type (ex. GET, POST)
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ord ...
- Android 学习之异常总结--java.lang.IllegalStateException:Could not execute method of the activity
在android学习过程中通常会遇到java.lang.IllegalStateException:Could not execute method of the activity这个错误:非法状态的 ...
- Spring Scheduled定时任务报错 java.lang.IllegalStateException: Encountered invalid @Scheduled method 'xxx': For input string: "2S"
报错信息如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ding ...
- java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method 解决办法
java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an in ...
- Caused by: java.lang.IllegalStateException: Method has too many Body parameters
feign多参数问题1.1GET方式错误写法 @RequestMapping(value="/test", method=RequestMethod.GET) Model test ...
随机推荐
- css 点击样式,水波纹(记录备用)
<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" ...
- hystrix配置
一.hystrix在生产中的建议 1.保持timeout的默认值(1000ms),除非需要修改(其实通常会修改) 2.保持threadpool的的线程数为10个,除非需要更多 3.依赖标准的报警和监控 ...
- pdm文件打开方式
转自:https://blog.csdn.net/qq_36855191/article/details/79299216 pdm打开网站:http://www.dmanywhere.cn/
- ECMAScript5面向对象技术(1)--原始类型和引用类型
概述 大多数开发者在使用Java或C#等基于类的语言的过程中学会了面向对象编程.由于JavaScript没有对类的正式支持,这些开发者在学习JavaScript时往往会迷失方向: JavaScript ...
- STM8 内部flash
举例 typedef enum { FLASH_MEMTYPE_PROG = (u8)0x00, /*!< Program memory */ FLASH_MEMTYPE_DATA = (u8) ...
- Java上传图片到服务器
HTML页面的标签 <div id="div_selectpic" align="right" style="width: 300px;font ...
- 【转】provisional headers are shown 知多少
前言 请求里面provisional headers are shown(显示临时报头) 出现的情况很多,但原因是多样的.如果你去直接匹配关键字搜索,得到的结果可能与你自己的情况大相径庭.网上大部分都 ...
- python函数式编程-装饰器
在代码运行期间动态增加功能的方式,称之为“装饰器”(Decorator). 由于函数也是一个对象,而且函数对象可以赋值给变量,所以通过变量也能调用该函数. >>> def now() ...
- RxJava 以及 Android 中的通用线程解决方案、并发与线程安全
关于RxJava如今是熟到发紫了,所以对于它底层的动作机制的了解是迫在眉睫了,费话不多说,直接开始. 这里还是以之前获取个人github仓库列表为例,用retrofit+rxjava,也是实际项目中用 ...
- Spring Boot 项目在 IntelliJ IDEA 中配置 DevTools 实现热部署(macOS 系统)
要配置的内容: 1.Preference -> Build, Execution, Deployment -> Complier -> Build project automatic ...