我有一个简单的Rest控制器,可以返回ResponseEntity
将返回值更改为ResponseEntity
java.lang.NullPointerException: null
at org.springframework.cloud.netflix.feign.support.ResponseEntityDecoder.decode(ResponseEntityDecoder.java:43)
at feign.SynchronousMethodHandler.decode(SynchronousMethodHandler.java:146)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:118)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:71)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:94)
at com.sun.proxy.$Proxy95.testPost(Unknown Source)
at com.test.TestResource.testGet(TestResource.java:20)
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:497)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
重新控制器:
@RestController
public class TestResource {
@RequestMapping(value = "/test", method = RequestMethod.GET, consumes="application/json", produces="application/json")
ResponseEntity<Void> testPost() {
return new ResponseEntity<>(HttpStatus.OK);
}
}
假装客户端访问rest资源:
@FeignClient("order-service")
public interface TestClient {
@RequestMapping(value = "/test", method = RequestMethod.GET, consumes="application/json", produces="application/json")
ResponseEntity<Void> testGet();
}
假装客户端的调用:
@Service
public class Test {
@Autowired
private TestClient testClient;
void test() {
testClient.testGet(); // this line triggers NPE
}
}
这个问题在1.0上得到了解决。x线和将在天使。SR4,它已经在布里克斯顿起作用了。M1,但我提前移植了测试。看见https://github.com/spring-cloud/spring-cloud-netflix/issues/539为了那份promise。
我的应用程序与一些外部服务集成,并向该服务请求数据。我只是想知道在客户端建模响应的最佳实践是什么,尤其是在客户端业务逻辑只需要一些数据的情况下。我正在考虑以下实施: 将JSON转换为包含所有数据/属性的类对象,并在我的代码中使用此类对象 将JSON转换为仅包含进一步处理所需的数据/属性的类对象 以上两者的组合(创建包含所有属性的类对象,然后将其转换为仅包含进一步业务逻辑所需属性的对象)
只是想知道有没有办法得到spring Web-Flux的web客户端的响应时间?
我想从服务器获取一个.json文件到客户端的.js文件 下面是app.js:(服务器代码) 我需要它在js文件:
我在创建用于单元测试的模拟响应对象时遇到了问题。我使用< code > org . glassfish . jersey . core . jersey-client 版本2.3.1来实现我的RESTful客户端,使用< code>mockito版本1.9.5来帮助我处理模拟对象。下面是我的测试代码: 执行 时会出现此问题。下面是该方法的代码: 请注意,我在嘲笑this.simpleClient。
我有一个API,当我通过邮递员调用它时,它会对以下情况做出以下回应: 案例1:状态代码:200 最后,我通过应用程序对它进行了测试,对于案例1,正如预期的那样,收到了状态代码为200的响应正文。但是对于第二种情况,由于状态代码是422,异常被抛出并得到处理,但是在异常对象中我们有响应对象,在它里面我们有响应实体。此响应实体为null,甚至studentResponse也为null。我想在422状态
在移动应用程序和Web服务之间有某种代理,我们在发出发布请求时对响应感到困惑。我们收到状态为200: OK的响应。但是我们找不到/提取JSON响应正文。 我们正在使用JAX-RS。有人能提供一些提示,从服务器响应中提取JSON主体(