I have searched much for this question, but didn't find resolved solution, so decide to ask new one here:
In my code, I created an Web client to call another Api, like below:
JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
SecurityServiceInternalV2 svc = JAXRSClientFactory.create(securityBaseUrl,
SecurityServiceInternalV2.class, Collections.singletonList(jsonProvider), true);
And this code is built as a library. the this lib is referenced by another application, and released.
But after that Api upgraded, there are extra fields are returned. SO when I still use my application to call that new Api and I got the error like:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "extra", not marked as ignorable
at [Source: (sun.net.www.protocol.http.HttpURLConnection$HttpInputStream); line: 1, column: 385]
obviously this is caused that when Jackson ObjectMapper deserialize the response body, it is failed when reading the Unknown property.
I know I can add some codes like:
jsonProvider.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
BUT, unfortunately, my situation is I can not change the code, since the application is released. I googled much of this issue, some ones told that a global setting can be configured in application.properties, like:
spring.jackson.deserialization.fail-on-unknown-properties=false
I tried this one, add this environment variable in my application, but looks like it does not work.
So here is my question, what I really need is this environment variable to set , so do not need to change codes.
Also in my case, the code to calling api and deserialization is in the dependency of my application, so setting this environment variable should also work in the dependency lib.
In my lib codes, I use the following java libraries:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.3.1</version>
</dependency>
and the Jackson json lib version is 2.10.0
com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider