SpringBoot 整合 FindReport 8.0

大憨熊 提交于 2020-10-24 06:50:34

1.创建springboot项目

2.生成webapp目录

3.复制FindReport WebRoor/WEN-INF 下如文件到项目webapp/WEN-INF

4.  安装FineReport包到本地仓库。注:自行修改-Dfile=后面的路径

call mvn install:install-file  -Dfile=D:\Aarea\Java\workJar\findreport_jar\fr-core-8.0.jar  -DgroupId=com.fr  -DartifactId=fr-core -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file  -Dfile=D:\Aarea\Java\workJar\findreport_jar\fr-report-8.0.jar  -DgroupId=com.fr  -DartifactId=fr-report -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file  -Dfile=D:\Aarea\Java\workJar\findreport_jar\fr-third-8.0.jar  -DgroupId=com.fr  -DartifactId=fr-third -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file  -Dfile=D:\Aarea\Java\workJar\findreport_jar\fr-performance-8.0.jar  -DgroupId=com.fr  -DartifactId=fr-performance -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file  -Dfile=D:\Aarea\Java\workJar\findreport_jar\fr-platform-8.0.jar  -DgroupId=com.fr  -DartifactId=fr-platform -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file  -Dfile=D:\Aarea\Java\workJar\findreport_jar\fr-chart-8.0.jar  -DgroupId=com.fr  -DartifactId=fr-chart -Dversion=8.0 -Dpackaging=jar

4.修改pom.xml,移除springboot嵌入式tomcat插件

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</exclusion>
	</exclusions>
</dependency>

<dependency>
	<groupId>javax.servlet</groupId>
	<artifactId>javax.servlet-api</artifactId>
	<version>3.1.0</version>
	<scope>provided</scope>
</dependency>

5. 添加FineReport依赖

<!-- findReport-->
<dependency>
	<groupId>com.fr</groupId>
	<artifactId>fr-report</artifactId>
	<version>${fr.version}</version>
</dependency>

<dependency>
	<groupId>com.fr</groupId>
	<artifactId>fr-core</artifactId>
	<version>${fr.version}</version>
</dependency>

<dependency>
	<groupId>com.fr</groupId>
	<artifactId>fr-third</artifactId>
	<version>${fr.version}</version>
</dependency>

<dependency>
	<groupId>com.fr</groupId>
	<artifactId>fr-performance</artifactId>
	<version>${fr.version}</version>
</dependency>

<dependency>
	<groupId>com.fr</groupId>
	<artifactId>fr-platform</artifactId>
	<version>${fr.version}</version>
</dependency>

<dependency>
	<groupId>com.fr</groupId>
	<artifactId>fr-chart</artifactId>
	<version>${fr.version}</version>
</dependency>

6. 新建 SpringbootStartApplication 继承 SpringBootServletInitializer 重写 configure 方法,让bulider指向原本main方法的类,这样就会在tomcat启动的时候启动spring-boot相关配置

public class SpringBootStartApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(FindReportApplication.class);
    }
}

7. 在原来的main方法中注入自己的Servlet,也就是ReportServlet

@SpringBootApplication
public class FindReportApplication {

    public static void main(String[] args) {
        SpringApplication.run(FindReportApplication.class, args);
    }

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        return new ServletRegistrationBean(new ReportServlet(), "/ReportServer");
    }

}

8.配置tomcat启动项目

进入数据决策系统:http://localhost:8080/ReportServer

查看指定报表数据: http://localhost:8080/ReportServer?reportlet=xxx.cpt

注意事项:

1.报表存放目录

2. 项目打包时:pom修改spring-boot打包方式为war

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!