SpringBoot整合FindReport8.0

编程

1.创建springboot项目

2.生成webapp目录

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

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

call mvn install:install-file -Dfile=D:AareaJavaworkJarfindreport_jarfr-core-8.0.jar -DgroupId=com.fr -DartifactId=fr-core -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file -Dfile=D:AareaJavaworkJarfindreport_jarfr-report-8.0.jar -DgroupId=com.fr -DartifactId=fr-report -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file -Dfile=D:AareaJavaworkJarfindreport_jarfr-third-8.0.jar -DgroupId=com.fr -DartifactId=fr-third -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file -Dfile=D:AareaJavaworkJarfindreport_jarfr-performance-8.0.jar -DgroupId=com.fr -DartifactId=fr-performance -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file -Dfile=D:AareaJavaworkJarfindreport_jarfr-platform-8.0.jar -DgroupId=com.fr -DartifactId=fr-platform -Dversion=8.0 -Dpackaging=jar

call mvn install:install-file -Dfile=D:AareaJavaworkJarfindreport_jarfr-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

以上是 SpringBoot整合FindReport8.0 的全部内容, 来源链接: utcz.com/z/518419.html

回到顶部