java - 将 xml 转换为带注释的 Java bean

标签 java spring jasper-reports javabeans

<bean id="pdf" class="org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView"
          p:url="classpath:jasperReports/test.jrxml"
          p:reportDataKey="datasource" />

尝试将上面的代码转换为带注释的@Bean,但失败了。有什么建议

最佳答案

尚未测试,只是创建对象并设置属性。当您尝试 Autowiring 时有任何细节/错误消息吗?

@Bean
public JasperReportsPdfView getJasperReports(){
    JasperReportsPdfView view = new JasperReportsPdfView();
    view.setUrl("classpath:jasperReports/test.jrxml");
    view.setReportDataKey("datasource");
    return view;
}

关于java - 将 xml 转换为带注释的 Java bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33958349/

相关文章:

java - 使用 jdbctemplate 将查询中的数据保存在模型中

spring - 如何在 Spring Boot 中从 [] 读取 List<String> 属性

java - 调试Spring配置不起作用

java - 如何将动态前景色应用于 JasperReport 中的文本字段

jasper-reports - JasperReports 导出到 Json 无法正确处理 "null"

java - 不能使用具有不同Spring Boot版本的库

java - object.notify() 不会唤醒 object.wait()

java - 从 XML 文档获取节点

java - eclipse 错误代码新手请

jasper-reports - 编译后的 .jasper 文件放在哪里