Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java-Class<;?扩展收藏>;_Java_Class_Jackson - Fatal编程技术网

Java-Class<;?扩展收藏>;

Java-Class<;?扩展收藏>;,java,class,jackson,Java,Class,Jackson,我想在下面的jackson反序列化中添加多个类。但是我该怎么做呢?下面是示例代码 XmlMapper mapper = new XmlMapper(); JaxbAnnotationModule module = new JaxbAnnotationModule(); mapper.registerModule(module); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(mapper.getTypeF

我想在下面的jackson反序列化中添加多个类。但是我该怎么做呢?下面是示例代码

XmlMapper mapper = new XmlMapper();
JaxbAnnotationModule module = new JaxbAnnotationModule();
mapper.registerModule(module);
AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
mapper.setAnnotationIntrospector(introspector);
TypeFactory typeFactory = mapper.getTypeFactory();
Class<? extends Collection> list;
MapType mapType = typeFactory.constructRawCollectionType(list);
File is = new File("myXMLFile.xml");
ArtworkContentMessageType je = mapper.readValue(is,mapType);
XmlMapper-mapper=new XmlMapper();
JaxbAnnotationModule=新的JaxbAnnotationModule();
映射器注册表模块(模块);
AnnotationIntrospector introspector=新的JaxbAnnotationIntrospector(mapper.getTypeFactory());
映射器setAnnotationIntrospector(内省器);
TypeFactory=mapper.getTypeFactory();
类是一个泛型类,这意味着它可以根据以下语法获取参数:

Class<T>

声明一个类,其类型是
集合的子类

,不确定您在问什么。是关于列表还是关于Class@ChrisNeve关于类你能举个例子“声明一个类型为集合子类的类”吗?我还不太清楚,你熟悉Java中的继承概念吗?一个类(称为子类或子类)可以使用extends关键字扩展另一个类(称为父类或超类)。
List<Class> clazz = new ArrayList<>();
clazz.add(ArtworkContentMessageType.class);
clazz.add(Body.class);
clazz.add(P.class);
MapType mapType = typeFactory.constructRawCollectionType(clazz);
Class<T>
Class<? extends Collection> list;