集成 fineReport
基于
spring boot 2.0
项目集成fineReport 10.0
环境
在项目中对应 module src 目录下创建webapp
文件并创建子文件WEB-INF
modules添加Web 并把webapp文件夹设置为Web Resource Directory
将%FineReport_HOME%\webapps\webroot\WEB-INF
目录下的所有文件复制到项目的WEB-INF
下
将%JAVA_HOME%/jdk/lib
下的tools.jar
复制到webapp的WEB-INF的lib文件夹下
修改 base-admin pom.xml
文件
修改打包方式为war
<packaging>war</packaging>
l
spring-boot-starter-tomcat
添加<scope>provided</scope>
否则<packaging>war</packaging>
可能为报错
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!-- 编译和测试的时候用 -->
<scope>provided</scope>
</dependency>
添加servlet依赖、去除boot内嵌tomcat
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot-starter.version}</version>
<!-- 去掉内嵌Tomcat依赖 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
修改启动类 继承 SpringBootServletInitializer
重写 configure
方法
import com.fastfinger.dev.listener.ApplicationStartupListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication
public class BaseApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(BaseApplication.class,args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
return builder.sources(FastAdminApplication.class);
}
}
添加artifacts
打开 project structure
选择 web module
put into output root
我这里是base-admin
配置tomcat
添加参数
-DDIAMOND.CONNECT.TIMEOUT=60000 -XX:MaxPermSize=3512m
这里会出现警告 没有关联 artifacts 点击fix
选择 之前配置的artifacts
继续往下拉 Application context设置为
/
(当前先不配置名称,spring boot部署到外部tomcat,如果有添加拦截器没处理好可能会出现404问题)
这里是配置运行后访问的路径 如Application context:/base
访问项目路径则为http://localhost:8080/base
点击运行TOMCAT
打开浏览器 输入 http://localhost:8080/decision/
完成
/decision
进入finereport后台
如果要在iframe显示自定义报表
<iframe src="/decision/view/report?viewlet=base/base.cpt"
width="100%" height="100%" frameborder="no" border="0"></iframe>`
base/base.cpt
的路径为项目的src/webapp/WEB-INF/reportlets
完成~