This code goal
I try to reqeust some api using RestTemplate
Now I used that
RestTemplate and normal ObjectMapper (not custom object)
I call this procedure
@Configuration
@ConfigurationProperties(prefix = "***********")
@Getter
@Setter
@ToString
public class RequestBody {
@JsonProperty("allFetched")
private Boolean enableAllFetched;
private String resultType;
private List<String> owners;
private List<String> statuses;
public RequestBody() {
}
public RequestBody(Boolean enableAllFetched, String resultType, List<String> owners, List<String> statuses) {
this.enableAllFetched = enableAllFetched;
this.resultType = resultType;
this.owners = owners;
this.statuses = statuses;
}
}
HttpEntity<RequestBody> requestBodyHttpEntity = new HttpEntity<>(requestBody);
restTemplate.exchange(properties.getUri(), HttpMethod.POST, requestBodyHttpEntity, ReponseDto.class, params);
I get below error detail explaination.
org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.springframework.context.expression.StandardBeanExpressionResolver]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: ****.***RequestBody$$EnhancerBySpringCGLIB$$16ef92cb["$$beanFactory"]->org.springframework.beans.factory.support.DefaultListableBeanFactory["beanExpressionResolver"])
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:341) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:104) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:943) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:737) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:695) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:593) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]
When I make new RequestBody
object, this logic worked.
But, I used to this RequestBody
bean object, I always get the upper message.
How can I do?
Comment From: philwebb
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Comment From: BaeJi77
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Thank you for your answer.