Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用带有参数/路径变量的querymap时,使用Feign-NPE_Java_Spring_Spring Cloud Feign_Feign_Openfeign - Fatal编程技术网

Java 使用带有参数/路径变量的querymap时,使用Feign-NPE

Java 使用带有参数/路径变量的querymap时,使用Feign-NPE,java,spring,spring-cloud-feign,feign,openfeign,Java,Spring,Spring Cloud Feign,Feign,Openfeign,我需要发出这样的请求host.com/filter1/filter2/filter3?param1={blah}¶m2={blah},我遇到了一些问题 我使用POJO来表示路径变量和请求参数。根据我在我的假客户中的描述: @FeignClient( name = "documentsFeignClient" ) public interface DocumentsFeignClient { @RequestLine( "GET /document

我需要发出这样的请求host.com/filter1/filter2/filter3?param1={blah}¶m2={blah},我遇到了一些问题

我使用POJO来表示路径变量和请求参数。根据我在我的假客户中的描述:

 @FeignClient( name = "documentsFeignClient" )
public interface DocumentsFeignClient
{

    @RequestLine( "GET /documents" +
                  "/{filters.entityType}" +
                  "/{filters.entityId}" +
                  "/{filters.documentType}" 
    @Headers( { "Content-Type: application/json",
                "X-User-Id: {userId}",
                "X-Tenant-Id: {tenantId}" } )
    Document getDocuments( @PathVariable( "filters" ) AttachedDocumentsFilters filters,
                           @QueryMap AttachedDocumentsQueryMap variablesQueryMap,
                           @Param( "userId" ) Long userId,
                           @Param( "tenantId" ) Long tenantId );

但是,当我从客户端调用时,使用空查询映射:
documentsFeignClient.getDocuments(filters,null,1L,1L)我从ReflectiveFeign.java中的这部分源代码中得到一个NPE:

    private RequestTemplate addQueryMapQueryParameters(Object[] argv, RequestTemplate mutable) {
      
      Map<Object, Object> queryMap = (Map<Object, Object>) argv[metadata.queryMapIndex()];
      for (Entry<Object, Object> currEntry : queryMap.entrySet()) {

private RequestTemplate addquerymaqueryparameters(对象[]argv,RequestTemplate可变){
Map queryMap=(Map)argv[metadata.queryMapIndex()];
对于(条目currEntry:queryMap.entrySet()){
特别是从queryMap中检索entrySet的行。奇怪的是,当我在客户端实际构建查询映射时,我得到了一个noSuchMethodError

我尝试了很多方法——切换参数的顺序(基于其他线程),将@QueryMap更改为@SpringQueryMap,等等,但都没有成功

如何解决这个问题?我想我可以为每个字段替换@QueryMap w/@RequestParam,但我想尝试避免这种情况,因为我们有4个请求参数,可能会添加更多。我使用的是Faign 9.5.0

提前谢谢你的帮助