我正在尝试将在java注释中完成的Birt应用程序转换为基于XML,但是“我很难将此部分更改为xml”
@Bean
public BirtViewResolver birtViewResolver() throws Exception {
BirtViewResolver bvr = new BirtViewResolver();
bvr.setBirtEngine(this.engine().getobject());
bvr.setViewClass(HtmlSingleFormatBirtView.class);
bvr.setDataSource(this.birtDataServiceConfiguration.dataSource());
bvr.setReportsDirectory("Reports");
bvr.setorder(2);
return bvr;
}
我尝试了这个,但无法弄清楚如何设置birtEngine,viewClass和dataSource部分
<beans:bean id="birtViewResolver" class="org.eclipse.birt.spring.core.BirtViewResolver">
<beans:property name="birtEngine" value="?" />
<beans:property name="viewClass" value="?" />
<beans:property name="dataSource" value="?" />
<beans:property name="reportsDirectory" value="Reports" />
<beans:property name="order" value="2" />
</beans:bean>
先感谢您
解决方法:
鉴于这种
bvr.setBirtEngine(this.engine().getobject());
我将假设engine()是另一个返回factorybean对象的@Bean方法.在XML中,您可以将其作为
<bean name="engine" class="com.example.Enginefactorybean" />
对于
bvr.setViewClass(HtmlSingleFormatBirtView.class);
Spring可以在XML中将完全限定的类名称作为字符串值转换为运行时的Class实例.
对于
bvr.setDataSource(this.birtDataServiceConfiguration.dataSource());
我将假设birtDataServiceConfiguration是对@Autowired的另一个@Configuration类的引用,dataSource()是在该类中声明的@Bean方法.
生成的XML声明就像
<!-- Assuming you converted that config to XML as well -->
<import resource="classpath:birtDataServiceConfiguration.xml" />
<beans:bean id="birtViewResolver" class="org.eclipse.birt.spring.core.BirtViewResolver">
<beans:property name="birtEngine" ref="engine" />
<!-- You would have to give the class' fully qualified name -->
<beans:property name="viewClass" value="com.example.fully.qualified.HtmlSingleFormatBirtView" />
<!-- Assuming that imported config had a bean declared with the name 'dataSource' -->
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="reportsDirectory" value="Reports" />
<beans:property name="order" value="2" />
</beans:bean>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。