Код: Выделить всё
//save command
...
try {
JAXBContext context = JAXBContext.newInstance(CollectionManager.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(collectionManager, new File("out.xml"));
} catch (JAXBException e) {
e.printStackTrace();
}
...
Код: Выделить всё
@XmlRootElement(name = "Collection")
@XmlAccessorType(XmlAccessType.FIELD)
public class CollectionManager {
...
@XmlElement(name = "MusicBand")
private PriorityQueue musicBandsQueue;
...
Код: Выделить всё
@XmlType(propOrder = {"id","name","coordinates", "numberOfParticipants", "creationDate", "albumsCount", "establishmentDate", "genre", "label"})
public class MusicBand implements Comparable {
private long id;
private String name;
private Coordinates coordinates;
private java.util.Date creationDate;
private int numberOfParticipants;
private Long albumsCount;
private java.time.ZonedDateTime establishmentDate;
private MusicGenre genre;
private Label label;
...
вот как это выглядит.
Код: Выделить всё
1
asd
1
1
1
1
SOUL
2
asd
1
Код: Выделить всё
org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Property creationDate appears in @XmlType.propOrder, but no such property exists. Maybe you meant coordinates?
this problem is related to the following location:
at ru.itmo.prog.lab5.collection.MusicBand.MusicBand
at private java.util.PriorityQueue ru.itmo.prog.lab5.CLI.Managers.CollectionManager.musicBandsQueue
at ru.itmo.prog.lab5.CLI.Managers.CollectionManager
at org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:83)
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:421)
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:255)
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1115)
at org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:144)
at org.glassfish.jaxb.runtime.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:44)
at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:373)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:546)
at ru.itmo.prog.lab5.CLI.Commands.Save.execute(Save.java:22)
at ru.itmo.prog.lab5.CLI.Managers.CommandManager.executeCommand(CommandManager.java:58)
at ru.itmo.prog.lab5.Main.main(Main.java:19)
Источник: https://stackoverflow.com/questions/781 ... perty-exis
Мобильная версия