我正在尝试使用JasperReports生成PDF文件,但是无论我如何尝试,它都给了我NullPointerException。
https://community.jaspersoft.com/questions/520803/getting-null-pointer-exception-fillreport
试图看那里,并更改了jasper属性文件,但是它什么也没做,而且我仍然遇到相同的错误。
尝试了绝对路径,相对路径,将资源作为流获取,什么都没有
这是我用来生成报告的代码
public String generateInvoiceFor (Reservation reservation) throws JRException {
JasperReport jasperReport = JasperCompileManager.compileReport("I:\\anoranzaHopefullyFinal\\src\\main\\resources\\jasper\\FacturaFinalFinal.jrxml");
List<Reservation> reservations = reservationService.getall();
JRBeanCollectionDataSource jrBeanCollectionDataSource = new JRBeanCollectionDataSource(reservations);
Map<String,Object> parameters = new HashMap<>();
parameters.put("Idparam",reservation.getId());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,jrBeanCollectionDataSource);
JasperExportManager.exportReportToPdfFile(jasperPrint,"jasper/jasperOutput/Factura.pdf");
return "Report successfully generated @path= jasper/jasperOutput/";
}