Java-Class<;?扩展收藏>;
我想在下面的jackson反序列化中添加多个类。但是我该怎么做呢?下面是示例代码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
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;