I have custompage class as follows
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DashboardResponseModel<T> extends PageImpl<T> {
private Integer count;
private Integer totalCount;
public DashboardResponseModel(List<T> content, Pageable pageable, Long total) {
super(content, pageable, total);
}
public DashboardResponseModel(List<T> content) {
super(content);
}
public DashboardResponseModel(List<T> content, Pageable pageable, Long total, Integer count,
Integer totalCount) {
super(content, pageable, total);
this.count = count;
this.totalCount = totalCount;
}
public DashboardResponseModel(List<T> content, Integer count, Integer totalCount) {
super(content);
this.count = count;
this.totalCount = totalCount;
}
Below is Fiegn configuration:
public class OKHTTPWithFeignClientConfiguration {
@Value("${spring.application.name}")
private String appName;
@Bean
public Contract feignContract() {
return new SpringMvcContract();
}
@Bean
public RequestInterceptor requestStartInterceptor() {
return new FeignRequestStartLoggerInterceptor();
}
@Bean
public RequestInterceptor requestTrackerInterceptor() {
return new FeignRequestTrackerInterceptor();
}
@Bean
public RequestInterceptor userAgentInterceptor(@Autowired Client client) {
return new FeignUserAgentInterceptor(appName, client.getClass().getPackageName());
}
@Bean
public ResponseInterceptor requestEndInterceptor() {
return new FeignRequestEndLoggerInterceptor();
}
@Bean
public OkHttpClient client() {
return new OkHttpClient();
}
@Bean
public Encoder encoder() {
return new JacksonEncoder(objectMapper());
}
@Bean
public Decoder decoder() {
return new JacksonDecoder(objectMapper());
}
private ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new PageJacksonModule());
objectMapper.registerModule(new SortJacksonModule());
return objectMapper;
}
I'm using Fiegn client to call other application and in response, I'm getting DashboardResponseModel
but fiegn client is not able to deserialize the response.
Below is the error:
Failed to narrow type [simple type, class com.abc.xyz.dashboard.model.DashboardResponseModel<com.abc.xyz.dashboard.model.EmployeeMissingInformationModel>] with annotation (value org.springframework.cloud.openfeign.support.PageJacksonModule$SimplePageImpl), from 'com.abc.xxyz.dashboard.model.DashboardResponseModel': Class
org.springframework.cloud.openfeign.support.PageJacksonModule$SimplePageImpl
not subtype ofcom.abc.xyz.dashboard.model.DashboardResponseModel<com.abc.xyz.dashboard.model.EmployeeMissingInformationModel>
reading PUT http://127.0.0.1:8312/v1.0/customer/32/registered-entity/7437/dashboard/missing-information/details?size=6&page=0
Is there any additional configuration needed for DashboardResponseModel to deserialize?