@Configuration
@ConditionalOnExpression(value="${sohelp-boot.engine.enabled:true} && ${sohelp-boot.engine.report.enabled:true}")
@ImportResource(value="classpath:ureport2.xml")
public class UReportConfiguration
extends Object
implements com.bstek.ureport.definition.datasource.BuildinDatasource
该配置类用于初始化 UReport 相关组件,包括自定义 Servlet、数据源、报表提供者等。
配置是否加载受属性 sohelp-boot.engine.enabled 和 sohelp-boot.engine.report.enabled 控制,
当这两个属性都为 true 时才加载此配置。
| 构造器和说明 |
|---|
UReportConfiguration() |
| 限定符和类型 | 方法和说明 |
|---|---|
com.bstek.ureport.provider.report.ReportProvider |
fileReportProvider()
根据资源配置类型决定使用的报表提供者(数据库或文件)。
|
Connection |
getConnection()
获取当前数据源连接对象。
|
ModuleDatasource |
getModuleDatasoure()
创建并注册模块化数据源 Bean。
|
MagicApiDatasource |
magicApiDatasource()
创建并注册 MagicAPI 数据源 Bean。
|
String |
name()
获取内置数据源名称。
|
SohelpReport |
sohelpReport()
创建并返回一个SoHelpReport实例。
|
org.springframework.boot.web.servlet.ServletRegistrationBean |
ureportServlet()
注册 UReport 的 Servlet,映射路径为 /ureport/*
|
@Bean public org.springframework.boot.web.servlet.ServletRegistrationBean ureportServlet()
@Bean(name="MagicApiDatasource") public MagicApiDatasource magicApiDatasource()
使用 SpringUtil 获取 MagicAPIService 实例,并将其封装成 MagicApiDatasource 提供给报表系统使用。
@Bean(name="ModuleDatasource") public ModuleDatasource getModuleDatasoure()
@Bean @ConditionalOnMissingBean(value=SohelpReport.class) public SohelpReport sohelpReport()
该方法使用@ConditionalOnMissingBean注解,表示仅在容器中不存在SohelpReport类型的Bean时才会创建。
@Bean public com.bstek.ureport.provider.report.ReportProvider fileReportProvider()
若资源类型为 database,则使用 DBReportProvider;否则使用 FileReportProvider。
public String name()
name 在接口中 com.bstek.ureport.definition.datasource.BuildinDatasourcepublic Connection getConnection()
尝试从注入的数据源中获取数据库连接,若发生异常则记录日志并返回 null。
getConnection 在接口中 com.bstek.ureport.definition.datasource.BuildinDatasourceCopyright © 2026. All rights reserved.