在润乾报表中添加 spring 定义的数据源
本篇简要介绍如何在 springboot 集成报表时,添加 spring 定义数据源
使用 springboot 快速开发项目时,我们可以在常用的 application.properties/application.yml 中设定数据源。
例如:
spring:
datasource:
url:…
driver-class-name: …
username: …
password: …
每个数据源都会有他的 beanfactory 实例名称。
上面写的数据源在 springboot beanfactory 中的名称默认为 dataSource。
当配置多数据源时需要按 springboot 的规则自定义 bean 来完成,这里不讲。在配置润乾报表时,我们要用到数据源的这个名称。在润乾报表配置中称为 id。
想要把这些数据源提供给润乾报表使用,可以进行如下配置。
打开润乾报表配置文件 raqsoftConfig.xml:
找到 Runtime 标签并在其中添加
<SpringDBList>
<DataSource name=“spring_ds_1”>
<property name=“id” value=“dataSource”/>
<property name=“type” value=“13”/>
</DataSource>
…
</SpringDBList>
这样在报表启动时就会把 springboot 定义的(名称为 dataSource,类型为 mysql,对应类型 13)数据源引入到报表应用中。报表应用可以识别 spring_ds_1 这个数据源。