根据jasper report server ultimate guide,我正在尝试使用其Java API从Jasperserver存储库检索资源,我应该获得ExecutionContext接口的实例:

ExecutionContext context = JasperServerUtil.getExecutionContext();

然后,获取RepositoryService接口的实例:
RepositoryService repositoryService = ...; //how??

现在,我可以使用以下代码获取文件:
FileResourceData fileResourceData = repositoryService.getContentResourceData(context, "/examples/report.pdf");

我的问题是如何获取RepositoryService实例?

最佳答案

ApplicationContext ctx = StaticApplicationContext.getApplicationContext();
String repositoryServiceName = "repositoryService";
RepositoryService repositoryService = (RepositoryService) ctx.getBean(repositoryServiceName);
ExecutionContext context = JasperServerUtil.getExecutionContext();
Resource resource = repositoryService.getResource(context, fileURI);

07-26 06:00