【发布时间】:2019-11-10 12:23:22
【问题描述】:
我正在尝试使用 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/";
}
【问题讨论】:
标签: spring-boot nullpointerexception jasper-reports