spring使用swagger这个错误怎么解决,项目能运行,就是一直报错误。
09:09:55.044 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.w.r.o.OperationResponseClassReader - Setting spring response class to:ServerResponse
09:09:55.044 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.r.o.OperationAuthReader - Authorization count 0 for method resetPassword
09:09:55.046 logback [RMI TCP Connection(9)-127.0.0.1] ERROR s.d.s.r.o.OperationHttpMethodReader - Invalid http method: postValid ones are [[Lorg.springframework.web.bind.annotation.RequestMethod;@5c8bcf2a]
java.lang.IllegalArgumentException: No enum constant org.springframework.web.bind.annotation.RequestMethod.post
at java.lang.Enum.valueOf(Enum.java:238) ~[na:1.8.0_171]
at org.springframework.web.bind.annotation.RequestMethod.valueOf(RequestMethod.java:35) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at springfox.documentation.swagger.readers.operation.OperationHttpMethodReader.apply(OperationHttpMethodReader.java:50) ~[springfox-swagger-common-2.4.0.jar:2.4.0]
at springfox.documentation.spring.web.plugins.DocumentationPluginsManager.operation(DocumentationPluginsManager.java:113) [springfox-spring-web-2.4.0.jar:2.4.0]
at springfox.documentation.spring.web.readers.operation.ApiOperationReader.read(ApiOperationReader.java:80) [springfox-spring-web-2.4.0.jar:2.4.0]
at springfox.documentation.spring.web.scanners.CachingOperationReader$1.load(CachingOperationReader.java:50) [springfox-spring-web-2.4.0.jar:2.4.0]
at springfox.documentation.spring.web.scanners.CachingOperationReader$1.load(CachingOperationReader.java:48) [springfox-spring-web-2.4.0.jar:2.4.0]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628) [guava-20.0.jar:na]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336) [guava-20.0.jar:na]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295) [guava-20.0.jar:na]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208) [guava-20.0.jar:na]
解决:
将小写post改成大写就好了 或者 @RequestMapping 注解增加 method = RequestMethod.POST
@ApiOperation(value="获取所有的区域信息", notes="获取区域列表", httpMethod = "GET", response =Area.class, produces = "application/json")
@RequestMapping(value = "/listarea", method = RequestMethod.GET)
或者
@ApiOperation(value="获取所有的区域信息", notes="获取区域列表", httpMethod = "POST", response =Area.class, produces = "application/json")
@RequestMapping(value = "/listarea", method = RequestMethod.POST)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。