环境:
- springboot 版本: 2.1.6.RELEASE
- springcloud 版本: Greenwich.SR2
异常信息如下:
17:30:01.128 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] ---> GET https://uat-xx.xx.cn/xx-api/xx/getXX?page=1&rows=10 HTTP/1.1
17:30:01.128 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] ---> END HTTP (0-byte body)
17:30:01.445 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] <--- HTTP/1.1 200 (317ms)
17:30:01.445 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] connection: keep-alive
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] content-type: application/json;charset=UTF-8
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] date: Tue, 14 Jan 2020 09:30:01 GMT
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] server: nginx/1.15.6
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] strict-transport-security: max-age=15724800; includeSubDomains
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] transfer-encoding: chunked
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] vary: Accept-Encoding
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] x-application-context: application
17:30:01.446 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx]
17:30:01.447 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] {"code":0,"msg":"success","data":{"pageSize":10,"totalCount":1,"pageNo":1,"totalPages":1,"datas":[{}]}}
17:30:01.447 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] DEBUG c.k.u.o.a.s.f.xxxService - [xxxService#getXxx] <--- END HTTP (2113-byte body)
17:30:01.462 [/] appName_IS_UNDEFINED [http-nio-8089-exec-9] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.Assert.noNullElements(Ljava/util/Collection;Ljava/lang/String;)V] with root cause
java.lang.NoSuchMethodError: org.springframework.util.Assert.noNullElements(Ljava/util/Collection;Ljava/lang/String;)V
at org.springframework.web.client.HttpMessageConverterExtractor.<init>(HttpMessageConverterExtractor.java:77)
at org.springframework.web.client.HttpMessageConverterExtractor.<init>(HttpMessageConverterExtractor.java:70)
at org.springframework.cloud.openfeign.support.SpringDecoder.decode(SpringDecoder.java:57)
at org.springframework.cloud.openfeign.support.ResponseEntityDecoder.decode(ResponseEntityDecoder.java:62)
at feign.optionals.OptionalDecoder.decode(OptionalDecoder.java:36)
at feign.SynchronousMethodHandler.decode(SynchronousMethodHandler.java:176)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:140)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy213.getXxx(Unknown Source)
at com.keking.union.oms.application.controller.WaybillController.queryInfo(WaybillController.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
猜测分析:
-
feign 调用结果已经返回
-
结果转换失败
-
应该是依赖版本的问题。 那么就要看 springcloud 版本依赖的 springboot 版本
在spring 官网查看了一下 Spring Cloud 的版本。
发现:
Release Train Version: Hoxton.RELEASE
Supported Boot Version: 2.2.1.RELEASE
于是尝试用这个版本。
好,尝试之后,发现还是不行。
那就不猜测了,直接怼吧。
问题解决:
其实报错信息很明显,java.lang.NoSuchMethodError: org.springframework.util.Assert.noNullElements
版本冲突这个思路是没错的。
我发现是我自己强制设置了 spring-web 的版本 为 5.2.0。 spring-core 的版本是 5.1.8。 把我设置的 spring-web 的依赖 删除即可。
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.2.0.RELEASE</version> </dependency>Ruh06 发布了48 篇原创文章 · 获赞 4 · 访问量 8万+ 私信 关注