带有 ArrayList 响应的 SelectableEntityFilteringFeature:无法解析 ID 为 'com.Profile' 的 PropertyFilter

SelectableEntityFilteringFeature with ArrayList Response: Can not resolve PropertyFilter with id 'com.Profile'

Dropwizard 应用程序

 environment.jersey().getResourceConfig()
                   .packages("com.resources")
                   .property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME,"fields")
                   .register(SelectableEntityFilteringFeature.class)
                   .register(JacksonFeature.class);

ProfileResource 中的方法

@GET
    @Path("/test/entity")
    @ApiOperation(value = "get profile", responseContainer = "List")
    @Timed
    @UnitOfWork
    public Response tesProfile(@QueryParam("profileId") List<String> profilesToInclude,
                                @QueryParam("fields") String fieldsToInclude) {
               Profile p = Profile.builder().firstName("x").lastName("y").build();
        Profile p1 = Profile.builder().firstName("a").lastName("b").build();
        Profile p2 = Profile.builder().firstName("c").lastName("d").build();
        List<Profile> profiles = new ArrayList<>();
        profiles.add(p);
        profiles.add(p1);
        profiles.add(p2);
        return Response.ok(profiles).build();
    }

错误

无法解析 ID 为 'com.Profile' 的 PropertyFilter;未配置 FilterProvider(通过引用链:java.util.ArrayList[0])

回应

400 错误请求

如果我尝试return响应中的单个配置文件而不是配置文件列表

,则相同的代码可以正常工作

javax.ws.rs.core.Response 接受 new GenericEntity<List<Profile>>(profileList){}。 所以我需要将列表转换为 GenericEntity,然后返回响应。成功了。