Java 如何在春季使用计划作业访问*.jasper文件?

Java 如何在春季使用计划作业访问*.jasper文件?,java,spring,web-applications,jasper-reports,scheduled-tasks,Java,Spring,Web Applications,Jasper Reports,Scheduled Tasks,我正在编写一个spring应用程序。我有一份像这样的预定工作 @Async @Scheduled(cron = "0 0 16 * * ?") public void createReport() { // argJasperPath = /WEB-INF/jasperFiles/myreport.jasper JasperPrint jasperPrint = JasperFillManager.fillReport(argJasperPath, argReportParams

我正在编写一个spring应用程序。我有一份像这样的预定工作

@Async
@Scheduled(cron = "0 0 16 * * ?")
public void createReport()
{
    // argJasperPath = /WEB-INF/jasperFiles/myreport.jasper
    JasperPrint jasperPrint = JasperFillManager.fillReport(argJasperPath, argReportParams, argDataSource);
    JasperExportManager.exportReportToPdfFile(jasperPrint, argOutputPath);
}
这将在每天16:00运行并创建报告。我正在使用JasperReports生成报告。我在/WEB-INF/jasperFiles/myreport.jasper下有myreport.jasper文件,当我在生成报告时运行作业时,我得到
FileNotFound exception

如何使用预定方法访问jasper文件

@Autowired
ServletContext context;

@Async
@Scheduled(cron = "0 0 16 * * ?")
public void createReport()
{
    // argJasperPath = /WEB-INF/jasperFiles/myreport.jasper
    JasperPrint jasperPrint = JasperFillManager.fillReport(context.getRealPath(argJasperPath), argReportParams, argDataSource);
    JasperExportManager.exportReportToPdfFile(jasperPrint, argOutputPath);
}

如果我们自动连接ServletContext,我们可以访问如下目录:
(context.getRealPath(argJasperPath)

您可以阅读post我如何在这个方法中使用ServletContext,这意味着预定方法?