SpringBoot整合ureport2

本文记录了在SpringBoot项目中整合ureport2时遇到的两个主要问题及其解决方法。首先,ureport.props属性定义冲突,通过在Spring配置中添加属性解决。其次,因jar包冲突导致页面加载500错误,通过排除aliyun-oss的低版本依赖解决冲突。
摘要由CSDN通过智能技术生成

Ureport整合BUG记录

背景介绍:

​ jeecg-boot开源版本没有开放报表功能,所以打算自己整合一个ureport2。整合过程入第一章,然后出现了错误,排错过程第二章。

一、springboot整合ureport2

  • pom.xml 添加dependency

    		<dependency>
    			<groupId>com.syyai.spring.boot</groupId>
    			<artifactId>ureport-spring-boot-starter</artifactId>
    			<version>2.2.9</version>
    		</dependency>	
    
  • 添加UreportConfig配置类

    package org.jeecg.config;
    
    import com.bstek.ureport.console.UReportServlet;
    import com.bstek
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UReport2 是一个基于 JasperReport 的开源报表工具,它的特点是支持在线设计报表、动态数据源、可视化配置等功能。Spring Boot 是一个快速开发框架,它可以帮助我们快速搭建 Web 应用程序。下面是 Spring Boot 整合 UReport2 的步骤。 1. 添加 UReport2 的依赖 在 pom.xml 文件中添加以下依赖: ```xml <dependency> <groupId>com.bstek.ureport</groupId> <artifactId>ureport2-console</artifactId> <version>2.8.10</version> </dependency> ``` 2. 配置 UReport2 在 application.properties 文件中添加以下配置: ```properties # UReport2 配置文件 ureport.config.location=classpath:ureport.xml ureport.temp.path=/tmp/ureport/ ureport.export.path=/tmp/ureport/export/ ureport.debug=true ``` 其中,ureport.config.location 指定 UReport2 的配置文件路径,ureport.temp.path 指定 UReport2 的临时文件路径,ureport.export.path 指定 UReport2 的导出文件路径,ureport.debug=true 表示启用 UReport2 的调试模式。 3. 配置数据源 在 application.properties 文件中添加以下配置: ```properties # 数据源配置 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.username=root spring.datasource.password=123456 ``` 其中,spring.datasource.driver-class-name 指定数据库驱动程序,spring.datasource.url 指定数据库连接地址,spring.datasource.username 和 spring.datasource.password 分别指定数据库用户名和密码。 4. 编写 UReport2 配置文件 在 resources 目录下创建 ureport.xml 文件,配置数据源和报表存储方式: ```xml <?xml version="1.0" encoding="UTF-8"?> <ureport> <!-- 配置数据源 --> <data-sources> <data-source name="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName">#{jdbc.driverClassName}</property> <property name="url">#{jdbc.url}</property> <property name="username">#{jdbc.username}</property> <property name="password">#{jdbc.password}</property> </data-source> </data-sources> <!-- 配置报表存储方式 --> <report-storage> <report-storage-in-file path="/tmp/ureport/files" /> </report-storage> </ureport> ``` 其中,data-source 标签用于配置数据源,report-storage 标签用于配置报表存储方式。 5. 创建报表模板 在 resources 目录下创建 report.ureport.xml 文件,用于定义报表模板。 6. 编写 Spring Boot Controller 在 Spring Boot 应用程序中创建一个 Controller,用于处理报表请求: ```java @RestController public class ReportController { @Autowired private ReportManager reportManager; @RequestMapping("/report") public void report(HttpServletRequest request, HttpServletResponse response) throws Exception { String id = request.getParameter("id"); ReportClient reportClient = reportManager.createReportClient("file:/tmp/ureport/files/" + id + ".ureport.xml", request, response); reportClient.execute(); } } ``` 其中,reportManager 是 UReport2 的报表管理器,用于创建报表客户端,report 方法用于处理报表请求,根据请求参数 id 加载对应的报表模板,并生成报表。 7. 运行应用程序 启动 Spring Boot 应用程序,并访问 http://localhost:8080/report?id=report,即可生成报表。其中,report 是报表模板的名称,可以根据实际情况进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值