Preface:
API method (
import org.codehaus.jackson.map.ObjectMapper;
)@SuppressWarnings("unchecked") public <T> T readValue(JsonParser jp, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readValue(copyDeserializationConfig(), jp, _typeFactory.constructType(valueType)); }
The ObjectMapper
class has the readValue
method above.
My custom class method (below) is working fine with no errors, but I see a "red Line" for the code line mapper.readValue(UserJson, in IntelliJ Idea...
private User serializeFromJsonString(String UserJson) throws Exception {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(UserJson, User.class);
}
An example with photo:
Thank you Stephan, LazerBass.. the "(File -> Invalidate caches)" didn't seem to work, I already tried it yesterday before I posted this Qn in stackOverflow.
The error didn't appear today.. Seems IDE overlooked into my dependencies..
Below dependency version is hardcoded in my Spring-boot application.
<!-- https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.4</version>
</dependency>
When I load a Maven project into IntelliJ Idea, it will ask to manually import the dependencies and for this "ObjectMapper" class, the IDE imported a 1.9.12 version of jackson-mapper-asl(in theory it has to take my 1.9.4 version hardcoded in my project). So I went and add additional 1.9.4 jar which is irrelevant, but just thought to check.
I did some more research and checked the "readValue" method of ObjectMapper class in all the versions(link: https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl) and surprisingly all the versions of this jackson-mapper-asl jar has this method in it.
Narrowing down, the issue seems to be with intelliJ Idea, ref: https://intellij-support.jetbrains.com/hc/en-us/community/posts/207108385-IntelliJ-not-able-to-resolve-classes-of-external-Libraries-for-Maven-projects