前提环境:我是在原有的SpringMVC+mybatis项目的开发环境上进行集成birt。
-
拷贝需要的文件到工程的WEB-INF目录里,
report-engine
tlds jrun.web.xml
server-config.wsdd
viewer.properties
-
给web.xml文件添加birt需要的上下文参数
<context-param> <param-name>BIRT_VIEWER_LOCALE</param-name> <param-value>en-US</param-value> </context-param> <!-- Default timezone setting. Examples: "Europe/Paris", "GMT+1". Defaults to the container's timezone. --> <context-param> <param-name>BIRT_VIEWER_TIMEZONE</param-name> <param-value></param-value> </context-param> <!-- Report resources directory for preview. Defaults to ${birt home} --> <context-param> <param-name>BIRT_VIEWER_WORKING_FOLDER</param-name> <param-value>business/reportfiles</param-value> </context-param> <!-- Temporary document files directory. Defaults to ${birt home}/documents --> <context-param> <param-name>BIRT_VIEWER_DOCUMENT_FOLDER</param-name> <param-value>WEB-INF/report-engine/documents</param-value> </context-param> <!-- Flag whether the report resources can only be accessed under the working folder. Defaults to true --> <context-param> <param-name>WORKING_FOLDER_ACCESS_ONLY</param-name> <param-value>true</param-value> </context-param> <!-- Settings for how to deal with the url report path. e.g. "http://host/repo/test.rptdesign". Following values are supported: <all> - All paths. <domain> - Only the paths with host matches current domain. Note the comparison is literal, "127.0.0.1" and "localhost" are considered as different hosts. <none> - URL paths are not supported. Defaults to "domain". --> <context-param> <param-name>URL_REPORT_PATH_POLICY</param-name> <param-value>domain</param-value> </context-param> <!-- Temporary image/chart directory. Defaults to ${birt home}/report/images --> <context-param> <param-name>BIRT_VIEWER_IMAGE_DIR</param-name> <param-value>WEB-INF/report-engine/images</param-value> </context-param> <!-- Engine log directory. Defaults to ${birt home}/logs --> <!-- <context-param> <param-name>BIRT_VIEWER_LOG_DIR</param-name> <param-value>WEB-INF/report-engine/logs</param-value> </context-param> --> <!-- Report engine log level [ALL|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST|OFF]--> <context-param> <param-name>BIRT_VIEWER_LOG_LEVEL</param-name> <param-value>OFF</param-value> </context-param> <!-- Directory where to store all the birt report script libraries (JARs). Defaults to ${birt home}/scriptlib --> <context-param> <param-name>BIRT_VIEWER_SCRIPTLIB_DIR</param-name> <param-value>WEB-INF/report-engine/scriptlib</param-value> </context-param> <!-- Resource location directory. Defaults to ${birt home} --> <context-param> <param-name>BIRT_RESOURCE_PATH</param-name> <param-value></param-value> </context-param> <!-- Preview report rows limit. An empty value means no limit. --> <context-param> <param-name>BIRT_VIEWER_MAX_ROWS</param-name> <param-value></param-value> </context-param> <!-- Max cube fetch levels limit for report preview (Only used when previewing a report design file using the preview pattern) --> <context-param> <param-name>BIRT_VIEWER_MAX_CUBE_ROWLEVELS</param-name> <param-value></param-value> </context-param> <context-param> <param-name>BIRT_VIEWER_MAX_CUBE_COLUMNLEVELS</param-name> <param-value></param-value> </context-param> <!-- Memory size in MB for creating a cube. --> <context-param> <param-name>BIRT_VIEWER_CUBE_MEMORY_SIZE</param-name> <param-value></param-value> </context-param> <!-- Defines the BIRT viewer configuration file --> <context-param> <param-name>BIRT_VIEWER_CONFIG_FILE</param-name> <param-value>WEB-INF/viewer.properties</param-value> </context-param> <!-- Flag whether to allow server-side printing. Possible values are "ON" and "OFF". Defaults to "ON". --> <context-param> <param-name>BIRT_VIEWER_PRINT_SERVERSIDE</param-name> <param-value>ON</param-value> </context-param> <!-- Flag whether to force browser-optimized HTML output. Defaults to true --> <context-param> <param-name>HTML_ENABLE_AGENTSTYLE_ENGINE</param-name> <param-value>true</param-value> </context-param> <!-- Filename generator class/factory to use for the exported reports. --> <context-param> <param-name>BIRT_FILENAME_GENERATOR_CLASS</param-name> <param-value>org.eclipse.birt.report.utility.filename.DefaultFilenameGenerator</param-value> </context-param>
如果需调整日志级别可修改BIRT_VIEWER_LOG_LEVEL的值为ALL;
可选的值有:ALL|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST|OFF。级别由高到低。 -
在web应用的目录下拷贝一下文件 webcontent
ds.rptlibrary(数据源配置) -
最后在pom.xml中,添加birt相关的jar包
<birt.version>4.4.1</birt.version> <dependency> <groupId>org.eclipse.birt.runtime</groupId> <artifactId>org.eclipse.birt.runtime</artifactId> <version>${birt.version}</version> </dependency> <dependency> <groupId>org.eclipse.birt.runtime</groupId> <artifactId>viewservlets</artifactId> <version>${birt.version}</version> </dependency>
最后,更新maven的jar包后,环境就搭建完成了。
添加的文件包,文件可以自己下载(地址:
http://www.eclipse.org/birt/
) ,当然,也可以下载我用到的文件
我用到的文件下载 eclipse集成birt报表时,用到的文件