JAXB를 사용하여 Java 객체를 XML로 정렬합니다. Windows OS에서 JDeveloper 11.1.1.7.0을 사용하고 있습니다. 나는 특정 자바 코드를 실행할 때마다 내가 코드에 오류 아직도 내가 ..JAXB를 사용하여 Java 객체를 XML로 마샬링
원하는 output..Please 도움말을 얻을 수 아니에요있을 것 같지에도 불구하고"Error(1,1): file:/C:/JDeveloper/mywork/bugdashboard/Model/src/model/BugReport.xml<Line 1, Column 1>: XML-20108: (Fatal Error) Start of root element expected."
를라는 오류 메시지가
내 자바 코드 ..
package model;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
public class JavaObvjecttoXml {
public void xmlGenerator() {
//super();
JavaServiceFacade fcd = new JavaServiceFacade();
bugvalue track, track1, track2;
List<ReportDto> bugReport, bugrePort1, bugrePort2;
List<bugvalue> reportMetaData= new ArrayList<bugvalue>();
ReportMetaData rmd = new ReportMetaData();
try {
rmd.setBugreportmetadata(new ArrayList<bugvalue>());
JAXBContext context = JAXBContext.newInstance(ReportMetaData.class);
Marshaller marshaller;
marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
track = new bugvalue();
bugReport = fcd.getBugSeverityReport();
track.setBugReport(bugReport);
track.setLabel("Bug by severity");
track.setTile("severity");
track.setChatType("PIE");
track.setXAxisLabel("Label");
track.setYAxisLAbel("Label Count");
track1 = new bugvalue();
bugrePort1 = fcd.getBugStatusReport();
track1.setBugReport(bugrePort1);
track1.setLabel("Bug by Status");
track1.setTile("status");
track1.setChatType("bar");
track1.setXAxisLabel("count");
track1.setYAxisLAbel("Label");
track2 = new bugvalue();
bugrePort2 = fcd.getBugCategoryReport();
track2.setBugReport(bugrePort2);
track2.setLabel("Bug by Category");
track2.setTile("category");
track2.setChatType("PIE");
track2.setXAxisLabel("count");
track2.setYAxisLAbel("Label");
reportMetaData.add(track);
reportMetaData.add(track1);
reportMetaData.add(track2);
rmd.setBugreportmetadata(reportMetaData);
File output = new File("C:\\JDeveloper\\mywork\\bugdashboard\\Model\\src\\model\\BugReport.xml");
marshaller.marshal(rmd, output);
}
catch(JAXBException e){
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
JavaObvjecttoXml obj = new JavaObvjecttoXml();
obj.xmlGenerator();
}
}
파일 ReportMetaData.java
package model;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
@ XmlRootElement(name = "ReportMetaData")
public class ReportMetaData {
private List<bugvalue> bugreportmetadata = new ArrayList<bugvalue>();
public List<bugvalue> getBugreportmetadata() {
return bugreportmetadata;
}
*/ @param bugreportmetadata
*/
public void setBugreportmetadata(List<bugvalue> bugreportmetadata) {
this.bugreportmetadata = bugreportmetadata;
}
public ReportMetaData() {
super();
}
}
ERR 또는 메시지 ..
위의 화면에서 볼 수 있듯이 파일 BugReport.xml
가 BugReport.xml가 생성되는 파일을 촬영하지만이 비어
..
'ReportMetaData' 클래스를 게시하십시오. – AlexR
@AlexR ReportMetaData 클래스를 추가했습니다 .. – Lucy
오류 메시지와 혼동 스러웠습니다. 생성 된 파일'BugReport.xml'을 보내주십시오. – AlexR