Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonInclude$Value

I am trying to convert my json string to java object and I am getting error

Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value at com.fasterxml.jackson.databind.cfg.MapperConfig.(MapperConfig.java:45) at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:535) at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:452) at com.allianz.cmis.util.ApacheHttpClientGet.main(ApacheHttpClientGet.java:65) Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonInclude$Value at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 4 more

Here is my json string and my code snippet

json string {'ctpnsw': [{'abc' , 'def' }]}

model

public class Fields {       private List<String> ctpnsw;      public List<String> getCtpnsw() {         return ctpnsw;     }      public void setCtpnsw(List<String> ctpnsw) {         this.ctpnsw = ctpnsw;     }  } 

Java code

ObjectMapper mapper = new ObjectMapper(); List<Fields> list = mapper.readValue(output, TypeFactory.defaultInstance().constructCollectionType(List.class,Fields.class)); System.out.println(list);

like image 410
user327126 Avatar asked Feb 23 '16 04:02

user327126


1 Answers

How about adding this to your pom.xml

<dependency>     <groupId>com.fasterxml.jackson.core</groupId>     <artifactId>jackson-annotations</artifactId>     <version>${jackson.version}</version> </dependency> 
like image 160
MonoThreaded Avatar answered Sep 27 '22 23:09

MonoThreaded