为什么我的 ArrayList 没有使用 JAXB 进行编组?
下面是一个用例:
@XmlRootElement
public class Book {
public String title;
public Book(String t) {
this.title = t;
}
}
@XmlRootElement
@XmlSeeAlso({Book.class})
public class Books extends ArrayList<Book> {
public Books() {
this.add(new Book("The Sign of the Four"));
}
}
然后,我正在做:
JAXBContext ctx = JAXBContext.newInstance(Books.class);
Marshaller msh = ctx.createMarshaller();
msh.marshal(new Books(), System.out);
这是我所看到的:
<?xml version="1.0"?>
<books/>
我的书在哪里?:)