java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonInclude$Value
2022-08-31 13:23:16
我正在尝试将我的json字符串转换为java对象,但我收到错误
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value
at com.fasterxml.jackson.databind.cfg.MapperConfig.<clinit>(MapperConfig.java:45)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:535)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(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
这是我的json字符串和我的代码片段
json 字符串{'ctpnsw': [{'abc' , 'def' }]}
型
public class Fields {
private List<String> ctpnsw;
public List<String> getCtpnsw() {
return ctpnsw;
}
public void setCtpnsw(List<String> ctpnsw) {
this.ctpnsw = ctpnsw;
}
}
Java 代码
`ObjectMapper mapper = new ObjectMapper();
List<Fields> list = mapper.readValue(output, TypeFactory.defaultInstance().constructCollectionType(List.class,Fields.class));
System.out.println(list);`