快速集成 === [TOC] ## #JeecgBoot快速集成 - 第一步: 引入 jimureport 依赖 jar 添加Maven依赖包 ``` <dependency> <groupId>org.jeecgframework.jimureport</groupId> <artifactId>spring-boot-starter-jimureport</artifactId> <version>1.2.0</version> </dependency> ``` - 第二步: 执行数据库脚本 Sql [jimureport.sql](https://github.com/zhangdaiscott/JimuReport/blob/master/db "jimureport.sql") - 第三步: 排除权限拦截 JimuReport自带权限控制,所以需要放开对JimuReport请求的权限拦截。 JeecgBoot请修改类org.jeecg.config.shiro.ShiroConfig 加入以下代码 (非JeecgBoot请按照自己权限规则排除) ``` //积木报表排除 filterChainDefinitionMap.put("/jmreport/**", "anon"); filterChainDefinitionMap.put("/**/*.js.map", "anon"); filterChainDefinitionMap.put("/**/*.css.map", "anon"); ``` - 第四步: 配置菜单 配置报表访问菜单 ``` {{ window._CONFIG['domianURL'] }}/jmreport/list?token=${token} ``` 参数说明 - {{ window._CONFIG['domianURL'] }} :后台项目访问地址 - ${token} :登录token用于权限控制 - 前端组件:layouts/IframePageView 菜单配置截图 ![](https://img.kancloud.cn/2b/28/2b28f238e4433fa1059c98c2a6e776e0_665x910.png) - 第五步: 进入报表列表 ![](https://oscimg.oschina.net/oscnet/up-3d2ab4d3eaaa1c011220e64003372988e28.png) - 第六步: 自定义权限实现类(如果不自定义,则报表所有请求都不做权限控制) Jeecgboot请复制类 [JimuReportTokenService.java](https://github.com/zhangdaiscott/JimuReport/blob/master/config/JimuReportTokenService.java)到项目中即可(类路径org.jeecg.config.jimureport),其他项目参考改造。 - 第七步: 检查jar依赖版本 ~~~ fastjson版本低可能造成无法解析问题 <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.75</version> </dependency> <!--引入commons-lang3--> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.10</version> </dependency> ~~~ ## #非JeecgBoot集成——额外步骤 > 前提: 采用SpringBoot+MybatisPlus的脚手架项目才支持与JimuReport集成。 - 第一步:启动类添加扫码路径 `org.jeecg.modules.jmreport` ``` @MapperScan(value={"org.jeecg.modules.**.mapper*"}) @SpringBootApplication(scanBasePackages = {"org.jeecg.modules.jmreport"}) ``` - 第二步:application.yml 增加配置属性 ``` spring: #静态资源 resource: static-locations: classpath:/static/,classpath:/public/ #配置freemarker freemarker: # 设置模板后缀名 suffix: .ftl # 设置文档类型 content-type: text/html # 设置页面编码格式 charset: UTF-8 # 设置页面缓存 cache: false prefer-file-system-access: false # 设置ftl文件路径 template-loader-path: - classpath:/templates #mybatis plus设置 mybatis-plus: mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml global-config: # 关闭MP3.0自带的banner banner: false db-config: id-type: ASSIGN_ID # 默认数据库表下划线命名 table-underline: true configuration: # 返回类型为Map,显示null对应的字段 call-setters-on-nulls: true #上传文件存储配置 jeecg : #local\minio\alioss uploadType: local path: upload:/opt/upload #阿里云oss oss: endpoint: oss-cn-beijing.aliyuncs.com accessKey: ?? secretKey: ?? bucketName: jeecgos staticDomain: ?? #minio文件 minio: minio_url: http://minio.jeecg.com minio_name: ?? minio_pass: ?? bucketName: otatest ``` - 第三步:配置jeecg私服,不然积木报表依赖下载不来 ``` <repositories> <repository> <id>jeecg</id> <name>jeecg Repository</name> <url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> ``` - 第四步:非jeecgboot项目集成可能缺少依赖,请参考下面配置加上 注意:版本号不一致也可能出冲突 ~~~ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.5.RELEASE</version> <relativePath/> </parent> ~~~ ``` <!--spring-boot --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.2</version> </dependency> <!-- freemarker --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> <!-- 动态数据源 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>dynamic-datasource-spring-boot-starter</artifactId> <version>3.2.0</version> </dependency> <!-- minio oss--> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>8.0.3</version> </dependency> ``` ## 集成视频 * [JeecgBoot2.1版本集成 JimuReport1.0.9实践](https://www.bilibili.com/video/BV1Y541147m1?p=25) * [ 积木报表全套视频 — JimuReport ](https://www.bilibili.com/video/BV1mK4y1H7NW) ## 附录 1、如果是老版本升级比如【1.1.02-beta升级到1.1.04-beta.】 还需要手工执行下 `增量升级SQL` ``` ALTER TABLE `jimu_report_db` ADD COLUMN `is_list` int(3) NULL DEFAULT 0 COMMENT '是否是列表0否1是 默认0' AFTER `api_method` ; update jimu_report_db set is_list=1,is_page=1 where api_url like '%pageSize%' or is_page=1; ```