6

Using this code :

import org.codehaus.jackson.map.ObjectMapper;
ObjectMapper objectMapper = new ObjectMapper();
String str = objectMapper.writeValueAsString(myObject);

I receive this Eclipse error:

The type org.codehaus.jackson.JsonGenerationException cannot be resolved. It is indirectly referenced from 
 required .class files

at line String str = objectMapper.writeValueAsString(myObject);

There are three 'JsonGenerationException' class types on my class path (you may have to save the image and open it separately to read the text in the image):

enter image description here

Is the reason I'm receiving this error message because JsonGenerationException is in two different jar files and Eclipse is unsure which on to use ? If so how can I fix it ?

I required this jar file : http://grepcode.com/snapshot/repo1.maven.org/maven2/org.codehaus.jackson/jackson-core-asl/1.9.4

4

2 に答える 2

12

Make sure that the JAR containing org.codehaus.jackson.JsonGenerationException is on your classpath, e.g., by using jackson-core-asl POM.

于 2012-12-06T22:58:48.483 に答える
1
import org.codehaus.jackson.map.ObjectMapper;

and also,you have to add jackson-core-asl-XXX.jar to build path.

于 2017-10-22T09:25:33.803 に答える