spring使用swagger这个错误怎么解决,项目能运行,就是一直报错误。

发布于 2022-09-07 20:19:17 字数 11979 浏览 21 评论 0

09:09:55.038 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.r.o.SwaggerOperationResponseClassReader - Setting response class to:ServerResponse
09:09:55.040 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.r.o.VendorExtensionsReader - Extension count 1 for method resetPassword
09:09:55.041 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.w.r.o.OperationModelsProvider - Adding return parameter of type Lcom/logic/common/ServerResponse;
09:09:55.041 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.w.r.o.OperationModelsProvider - Reading parameters models for handlerMethod |resetPassword|
09:09:55.042 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.w.r.o.OperationModelsProvider - Finished reading parameters models for handlerMethod |resetPassword|
09:09:55.042 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.r.o.SwaggerOperationModelsProvider - Reading parameters models for handlerMethod |resetPassword|
09:09:55.042 logback [RMI TCP Connection(9)-127.0.0.1] DEBUG s.d.s.web.scanners.ApiModelReader - Generated parameter model id: ServerResponse, name: ServerResponse, schema: {} models
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]
    at com.google.common.cache.LocalCache.get(LocalCache.java:4053) [guava-20.0.jar:na]
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057) [guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986) [guava-20.0.jar:na]
    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4992) [guava-20.0.jar:na]
    at springfox.documentation.spring.web.scanners.CachingOperationReader.read(CachingOperationReader.java:57) [springfox-spring-web-2.4.0.jar:2.4.0]
    at springfox.documentation.spring.web.scanners.ApiDescriptionReader.read(ApiDescriptionReader.java:70) [springfox-spring-web-2.4.0.jar:2.4.0]
    at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:89) [springfox-spring-web-2.4.0.jar:2.4.0]
    at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:69) [springfox-spring-web-2.4.0.jar:2.4.0]
    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:105) [springfox-spring-web-2.4.0.jar:2.4.0]
    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent(DocumentationPluginsBootstrapper.java:91) [springfox-spring-web-2.4.0.jar:2.4.0]
    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent(DocumentationPluginsBootstrapper.java:53) [springfox-spring-web-2.4.0.jar:2.4.0]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:546) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java) [spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443) [spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325) [spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792) [catalina.jar:8.5.32]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256) [catalina.jar:8.5.32]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.32]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754) [catalina.jar:8.5.32]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) [catalina.jar:8.5.32]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.32]
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1736) [catalina.jar:8.5.32]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.5.32]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_171]
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_171]
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:483) [catalina.jar:8.5.32]
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:432) [catalina.jar:8.5.32]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.5.32]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_171]
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_171]
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_171]
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_171]
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_171]
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_171]
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java) ~[na:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) [na:1.8.0_171]
    at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_171]
    at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_171]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_171]
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_171]
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) [na:1.8.0_171]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:835) [na:1.8.0_171]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) [na:1.8.0_171]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_171]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) [na:1.8.0_171]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_171]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_171]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_171]

这是类上面的注解

clipboard.png

Spring版本

clipboard.png

Swagger版本

clipboard.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

红ご颜醉 2022-09-14 20:19:17

图片描述我的解决方法是把@ApiOperation(value="导入Excel",httpMethod ="post" ,response=List.class ,notes="批量导入用户名和密码")里面的httpMethod ="post"删除

灼疼热情 2022-09-14 20:19:17

感谢@就是 提供的思路

将小写post改成大写就好了

clipboard.png

clipboard.png

难以启齿的温柔 2022-09-14 20:19:17

@RequestMapping 注解增加 method = RequestMethod.POST

海的爱人是光 2022-09-14 20:19:17

I have got the same issue in spring boot version 1.5.3.RELEASE(2.0.8.RELEASE is the seame problem), but could resolve it by adding guava version 20.0.

原文

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>20.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文