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 ...
随机推荐
- java第一次笔试+面试总结
今天是自己第一次java笔试和面试,总体感觉比预期好一点. 笔试题第一面是问答题,主要考查java基础,一共有18题,我有6道题没有写出来.第二面主要是算法题,一共有8道题,我大概写出来4道题,第三面 ...
- 拦截器中获取不到controller注解问题
刚刚在测试接口的时候发现一个奇怪的问题:通过拦截器获取 controller 类注解,有些能获取到,有些又不能获取到,见鬼了. [环境]: 1. springboot :2.2.0.RELEASE [ ...
- vue中计算属性和侦听属性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Zabbix MySQL percona 模板部署
Zabbix MySQL percona服务端执行以下操作https://www.zabbix.com/download?zabbix=4.0&os_distribution=centos&a ...
- inotify文件监控
参考:xxxx /*************************************************************************\* Copyright (C) M ...
- 快上车,react 入门拾遗
最近朋友圈和微博都刷了一波杰伦的回忆杀–说好不哭,想想都9012了,在学习react如火如荼的路上,也不妨停下脚步来总结总结,朝花夕拾一下. 为了便于阐述,我们还是来段小明和禅师的故事吧. 小明在学习 ...
- 检查shell脚本
1.检查solr服务监控脚本: #/bin/bash starttime=$(date +%Y-%m-%d\ %H:%M:%S) http_code=$(curl -I -m -o /dev//sol ...
- django实现发送邮件功能
django实现邮件发送功能 1)首先注册一个邮箱,这里以163邮箱为例 2)注册之后登录,进行如下修改 找到设置,设置一个授权码,授权码的目的仅仅是让你有权限发邮件,但是不能登录到邮箱进行修改,发送 ...
- 看完100篇Python技术精华文章,平均涨薪30%!
一个以技术为立身根基的教育机构做出来的微信号,干货程度会有多高? 马哥Linux运维公众号运营五年,从一开始的定位就是给技术人分享加薪干货的地方.这五年里,公众号运营最重的任务就是做内容.内容并不好做 ...
- MySql 数据库 SQLException: The user specified as a definer ('root'@'%') does not exist 错误原因及解决办法
The user specified as a definer ('root'@'%') does not exist 此种报错主要是针对访问视图文件引起的(没有权限) 经查明:是用户root并没有获 ...