SpringBoot2.1.1集成FineReport

在参考客服给的文档后,再加上自己的一些摸索,找到了可用的方法,记录一下。

环境说明:

  • SpringBoot 2.1.1.RELEASE
  • FineReport 10.0
  • Tomcat 9.0.13
  • java version "1.8.0_192"

集成步骤:

1. 安装jar包。官方文档 嵌入式部署 中指出所有‘fine’开头的jar包都是必须导入的。

call mvn install:install-file -Dfile=fine-accumulator-10.0.jar -DgroupId=com.fine -DartifactId=fine-accumulator -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-activator-10.0.jar -DgroupId=com.fine -DartifactId=fine-activator -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-core-10.0.jar -DgroupId=com.fine -DartifactId=fine-core -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-datasource-10.0.jar -DgroupId=com.fine -DartifactId=fine-datasource -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-decision-10.0.jar -DgroupId=com.fine -DartifactId=fine-decision -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-decision-report-10.0.jar -DgroupId=com.fine -DartifactId=fine-decision-report -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-report-engine-10.0.jar -DgroupId=com.fine -DartifactId=fine-report-engine -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-schedule-10.0.jar -DgroupId=com.fine -DartifactId=fine-schedule -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-schedule-report-10.0.jar -DgroupId=com.fine -DartifactId=fine-schedule-report -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-swift-log-adaptor-10.0.jar -DgroupId=com.fine -DartifactId=fine-swift-log-adaptor -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-third-10.0.jar -DgroupId=com.fine -DartifactId=fine-third -Dversion=10.0 -Dpackaging=jar
call mvn install:install-file -Dfile=fine-webui-10.0.jar -DgroupId=com.fine -DartifactId=fine-webui -Dversion=10.0 -Dpackaging=jar

2. pom.xml中添加依赖。这里把 fine-swift-log-adaptor 包注释了,因为发现导入这个包后会一直报错,因为暂时用不到就先注释掉,之后再研究。



    com.fine
    fine-accumulator
    10.0


    com.fine
    fine-activator
    10.0


    com.fine
    fine-core
    10.0


    com.fine
    fine-datasource
    10.0


    com.fine
    fine-decision
    10.0


    com.fine
    fine-decision-report
    10.0


    com.fine
    fine-report-engine
    10.0


    com.fine
    fine-schedule
    10.0


    com.fine
    fine-schedule-report
    10.0



    com.fine
    fine-third
    10.0


    com.fine
    fine-webui
    10.0

3.  修改项目的打包方式为 war,禁用集成的 Tomcat


    org.springframework.boot
    spring-boot-starter-tomcat
    provided

4. 修改启动类,使启动类继承 SpringBootServletInitializer,添加 @EnableAutoConfiguration 注解,重写 configure方法

@SpringBootApplication
@EnableAutoConfiguration
public class DemoApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}
	
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(DemoApplication.class);
	}
}

5. 拷贝tools.jar。详情参考:服务器部署需引入tools.jar。

6. 在src/main下新建 webapps/WEB-INF/reportlets/,将报表放置在此文件夹下。如下图:

SpringBoot2.1.1集成FineReport_第1张图片

7. 配置Tomcat的 Timeouts 设置 。本机上的启动时间是60多秒,所以设置为90秒。如上图:

8. (可选)修改访问路径。修改 server.xml 中的 Context标签的 path 属性为“/”,如下图:

SpringBoot2.1.1集成FineReport_第2张图片

9. 访问路径说明。

  • 如果步骤8不中 path 设置为了 “/”
  1. 数据决策系统的访问路径 http://localhost:8080/decision

  2. 报表的访问路径是 http://localhost:8080/decision/view/report?viewlet=GettingStarted.cpt

  3. 自己项目中controller的访问路径是 http://localhost:8080/web

  • 如果步骤8中未修改 path
  1. 数据决策系统的访问路径 http://localhost:8080/demo/decision
  2. 报表的访问路径是 http://localhost:8080/demo/decision/view/report?viewlet=GettingStarted.cpt
  3. 自己项目中controller的访问路径是 http://localhost:8080/demo/web

你可能感兴趣的:(Web)