我正在尝试将在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>
提前谢谢
答案 0 :(得分:4)
鉴于此
bvr.setBirtEngine(this.engine().getObject());
我将假设engine()
是另一个返回@Bean
对象的FactoryBean
方法。在XML中,您可以将其作为
<bean name="engine" class="com.example.EngineFactoryBean" />
有关
bvr.setViewClass(HtmlSingleFormatBirtView.class);
Spring可以在XML中将完全限定的类名称作为字符串值转换为运行时的Class
实例。
有关
bvr.setDataSource(this.birtDataServiceConfiguration.dataSource());
我将假设birtDataServiceConfiguration
是对您@Configuration
@Autowired
和dataSource()
为@Bean
的另一个<!-- 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>
课程的引用在该类中声明的方法。
生成的XML声明就像
{{1}}