我正在尝试在我的 Spring 项目中使用 Birt ReportEngine。我已经成功生成了一个在 Eclipse 中工作的 report.rptdesign。 现在我想在我的应用程序中使用这个“report.rptdesign”并生成某种输出(PDF/HTML,无关紧要)。 我已经添加了
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.2.2</version>
</dependency>
进入我的 pom.xml。此外,我已经为
添加(并手动创建)两个路径-Dorg.eclipse.datatools_workspacepath=C:\apache-tomcat-7.0.30\temp\workspace_dtp
-Dorg.eclipse.datatools.connectivity_workspacepath=C:\apache-tomcat-7.0.30\temp\workspace_dtp\org.eclipse.datatools.connectivity
但我多次收到错误。
org.eclipse.datatools.connectivity.internal.ConnectivityPlugin log
SEVERE: Error loading connection profile data.
org.eclipse.datatools.connectivity.internal.ConnectivityPlugin log
SEVERE: Error saving connection profile data.
我的 report.rptdesign 使用“db”文件连接到我在 report.rptdesign 中正确引用的数据库
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc.dbprofile" name="DB MySql" id="18">
....
<property name="OdaConnProfileStorePath">C:\workspace-sts\myproject\test\db</property>
</oda-data-source>
</data-sources>
更新: 我使用的代码:
DesignConfig config = new DesignConfig();
Platform.startup(config);
IDesignEngineFactory factory = (IDesignEngineFactory) Platform.createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);
IDesignEngine designEngine = factory.createDesignEngine(config);
SessionHandle session = designEngine.newSessionHandle(ULocale.ENGLISH);
ReportDesignHandle designHandle = session.openDesign("myReport.rtpdesign");
ElementFactory designFactory = designHandle.getElementFactory();
designHandle.close();
EngineConfig engineConfig = new EngineConfig();
Platform.startup(engineConfig);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
IReportEngine reportEngine = factory.createReportEngine(engineConfig);
IReportRunnable design = reportEngine.openReportDesign(designHandle);
IRunAndRenderTask task = reportEngine.createRunAndRenderTask(design);
我需要将“db”文件放在其他地方吗?我在类路径等中尝试了几个位置。
问候, 曼纽尔
最佳答案
如果连接配置文件存储设置为相对路径,则必须在启动平台之前向 birt 引擎配置提供 resourcePath。例如:
engineConfig.setResourcePath("/myResourcePath");
相对于此资源路径搜索连接存储。
关于java - Birt 连接配置文件的 ODA 配置文件存储路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23081082/