【发布时间】:2014-04-15 10:30:08
【问题描述】:
我正在尝试在我的 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”文件放在其他地方吗?我在类路径等中尝试了几个位置。
问候, 曼努埃尔
【问题讨论】:
-
您没有在问题中使用“Spring”标签是否有原因?您说您的设计在 Eclipse 内部工作,因此可能与您的 Spring 框架有关。
-
我已经添加了弹簧标签,谢谢。 (但我认为这与弹簧无关)
-
从 birt 4.2 开始,我们可以为连接配置文件存储设置相对路径,你考虑过这个选项吗?你是从自己的 java 代码启动 birt 引擎的吗?
-
是的,我也尝试过“数据源”中的相对路径。是的,它已集成在我的代码中。