Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fegin接口GET方法,使用@RequestBody 注解参数异常 #5

Open
panjianping opened this issue Apr 10, 2019 · 4 comments
Open

fegin接口GET方法,使用@RequestBody 注解参数异常 #5

panjianping opened this issue Apr 10, 2019 · 4 comments

Comments

@panjianping
Copy link

panjianping commented Apr 10, 2019

  1. spring-boot 版本为 2.0.8 ; spring-cloud 版本为F版SR2
  2. fegin接口定义
@GetMapping("/api/comment/ids")
ResponseVo<Integer> findCommentTmp(@RequestBody ArrayList<Long> ids);
  1. 实现类1:加@RequestBody
@Override
public ResponseVo<Integer> findCommentTmp(@RequestBody ArrayList<Long> ids) {
	log.info("ids:{}",ids);
	return null;
}

报错(没有集成venus-cloud-feign是正常的):

org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public com.lx.core.model.ResponseVo<java.lang.Integer> com.lx.comment.api.CommentApiServiceImpl.findCommentTmp(java.util.ArrayList<java.lang.Long>)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:160)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:130)
	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:124)
	at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:131)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:891)
	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:991)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:873)
  1. 实现类2:不加@RequestBody
@Override
public ResponseVo<Integer> findCommentTmp(ArrayList<Long> ids) {
	log.info("ids:{}",ids);
	return null;
}

错误: ids 始终为空值

  1. 如果接口使用POST方法,参数使用@RequestBody,实现类参数加不加@RequestBody,都是正常的能获取ids值
@SoftwareKing
Copy link
Member

@panjianping spring-cloud 版本为F版SR2,目前venus-cloud-feign升级,没有做适配

@panjianping
Copy link
Author

@SoftwareKing 意思是当前 venus-cloud-feign-1.0.0 没有对 spring-cloud的F版FSR2 没有做适配是吧?

@SoftwareKing
Copy link
Member

@panjianping

@dxxyz
Copy link

dxxyz commented Sep 20, 2019

直接用@SpringQueryMap注解试试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants