简体   繁体   English

将xml转换为带注释的bean Java

[英]Convert xml to annotated bean Java

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

Trying to convert the above code to annoted @Bean but failed to do. 试图将上面的代码转换为带注释的@Bean但失败了。 Any suggestions 有什么建议么

Haven't tested it, but just create the object and set the attributes. 还没有测试过,只是创建对象并设置属性。 Any specifics/error messages when you try to autowire it? 尝试自动接线时是否有任何详细信息/错误消息?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM