为什么 Jasper 支持从 Spring Framework 5.x 中退出?
Why was Jasper support dropped out from Spring Framework 5.x?
我们一直在使用带有 Spring Boot 的 Jasper 来实现我们项目的报告功能,但根据 Spring Framework 5.x release documentation Jasper 支持已被取消。
- 请问为什么要这样做?
他们建议继续使用 Spring Framework 4。3.x 以防我们需要 Jasper 支持。
- 如果我们想升级到 Spring Framework 5.x 并且仍然使用 Jasper,有什么替代方法吗?
您的问题的两个部分都在跟踪被删除的支持的 JIRA ticket 中得到了回答。
我可以知道为什么这样做吗?
After some investigation, the new Exporter API in JasperReports is designed for upfront configuration in the form of ExporterInput / ExporterOutput objects, not lending itself to the piecemeal approach in Spring's JasperReports view class hierarchy and in particular not to the declarative configuration style typically used there. Even aside from that, we'd have to redesign our entire JasperReports view support in an severely incompatible way, due to the wide-ranging API changes across the JasperReports configuration model.
如果我们想升级到 Spring Framework 5.x 并且仍然使用 Jasper,有什么替代方法吗?
As a consequence, we rather recommend native use of the JasperReports API in Spring MVC handler methods, generating reports from specifically designed RESTful endpoints.
我们已升级到 Jaspersoft 6.8.1(开源) 和 Jaspersoft Pro 7.3.1 Spring5.1.20。我们在升级时发现了以下问题:
- 最初字体扩展不起作用。所以,我们创造了它
再次使用 Jaspersoft 7.3.1 Studio。
- Jasperreports 中引入了一个名为 jrs.configs.js 的 js 文件 Highcharts 库未加载,因此我们的 Highcharts 未在嵌入式环境中加载。我们已将该文件放在它在我们的网络应用程序中搜索的位置。之后,一切正常。
我不得不升级到 Spring 5,这对我有用:
@GetMapping(value = "/report1")
public void getPdf(HttpServletResponse response) throws JRException, IOException {
InputStream jasperStream = this.getClass().getResourceAsStream("/jasperreports/HelloWorld1.jasper");
Map<String,Object> params = new HashMap<>();
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(jasperStream);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
response.setContentType("application/x-pdf");
response.setHeader("Content-disposition", "inline; filename=helloWorldReport.pdf");
final OutputStream outStream = response.getOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, outStream);
}
我们一直在使用带有 Spring Boot 的 Jasper 来实现我们项目的报告功能,但根据 Spring Framework 5.x release documentation Jasper 支持已被取消。
- 请问为什么要这样做?
他们建议继续使用 Spring Framework 4。3.x 以防我们需要 Jasper 支持。
- 如果我们想升级到 Spring Framework 5.x 并且仍然使用 Jasper,有什么替代方法吗?
您的问题的两个部分都在跟踪被删除的支持的 JIRA ticket 中得到了回答。
我可以知道为什么这样做吗?
After some investigation, the new Exporter API in JasperReports is designed for upfront configuration in the form of ExporterInput / ExporterOutput objects, not lending itself to the piecemeal approach in Spring's JasperReports view class hierarchy and in particular not to the declarative configuration style typically used there. Even aside from that, we'd have to redesign our entire JasperReports view support in an severely incompatible way, due to the wide-ranging API changes across the JasperReports configuration model.
如果我们想升级到 Spring Framework 5.x 并且仍然使用 Jasper,有什么替代方法吗?
As a consequence, we rather recommend native use of the JasperReports API in Spring MVC handler methods, generating reports from specifically designed RESTful endpoints.
我们已升级到 Jaspersoft 6.8.1(开源) 和 Jaspersoft Pro 7.3.1 Spring5.1.20。我们在升级时发现了以下问题:
- 最初字体扩展不起作用。所以,我们创造了它 再次使用 Jaspersoft 7.3.1 Studio。
- Jasperreports 中引入了一个名为 jrs.configs.js 的 js 文件 Highcharts 库未加载,因此我们的 Highcharts 未在嵌入式环境中加载。我们已将该文件放在它在我们的网络应用程序中搜索的位置。之后,一切正常。
我不得不升级到 Spring 5,这对我有用:
@GetMapping(value = "/report1")
public void getPdf(HttpServletResponse response) throws JRException, IOException {
InputStream jasperStream = this.getClass().getResourceAsStream("/jasperreports/HelloWorld1.jasper");
Map<String,Object> params = new HashMap<>();
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(jasperStream);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
response.setContentType("application/x-pdf");
response.setHeader("Content-disposition", "inline; filename=helloWorldReport.pdf");
final OutputStream outStream = response.getOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, outStream);
}