SpringBoot2.1整合finereport10(帆軟報表)


  最近,公司采購了帆軟的系統,領導安排要與公司的SpringBoot框架進行整合。費了一番牛勁,終於整合成功,下面分享一下我的經驗。

  首先,我的開發環境是Intellij IDEA,使用的SpringBoot版本是2.1.1,整合的finereport版本是10.0。

  一、根據帆軟官方教程 http://help.finereport.com/ 高級教程->部署集成->服務器部署->報表部署流程->嵌入式部署的介紹,

 

 

 

%FineReport_HOME%\webapps\webroot\WEB-INF目錄下面的assets、assist、classes、embed、lib、plugins、reportlets七個文件夾復制到你的項目的webapp的WEB-INF文件夾下,再%JAVA_HOME%/jdk/lib下的tools.jar拷貝到你的項目的webapp的WEB-INF的lib文件夾下,如圖所示:

 

 

 

   注意,springboot框架默認是不帶webapp文件夾以及其子文件夾WEB-INF的,此時需要自己創建這兩個文件夾,並將webapp文件夾設置為Web Resource Directory。(通過Project Structure設置)

 

  二、更改SpringBoot的配置(打包方式/啟動方式)

  1.修改pom文件

  (1)修改打包方式為war

  

  (2)修改pom依賴的包,添加servlet依賴,去掉內嵌Tomcat依賴,添加servlet-api依賴:

  

 1     <dependencies>
 2         <dependency>
 3             <groupId>org.springframework.boot</groupId>
 4             <artifactId>spring-boot-starter-web</artifactId>
 5             <exclusions>
 6                 <exclusion>
 7                     <groupId>org.springframework.boot</groupId>
 8                     <artifactId>spring-boot-starter-tomcat</artifactId>
 9                 </exclusion>
10             </exclusions>
11         </dependency>
12         <dependency>
13             <groupId>javax.servlet</groupId>
14             <artifactId>javax.servlet-api</artifactId>
15             <version>3.1.0</version>
16             <scope>provided</scope>
17         </dependency>
18     </dependencies>

  2.修改啟動文件

  

  3.在idea中設置項目以tomcat方式啟動

  (1)

  

  (2)

             

  

  (3)

  

  點擊Fix時,選擇第一個即可。

  

  附一張最后的項目結構圖:

  

 

 

  三、啟動程序

  在地址欄中輸入http://ip:端口號/項目目錄/decision,能成功顯示下圖頁面,則表明SpringBoot集成FineReport成功。

  

   項目源代碼鏈接:

  第一部分:https://download.csdn.net/download/weixin_44299969/10894741

  第二部分:https://download.csdn.net/download/weixin_44299969/10894769

  第三部分:https://download.csdn.net/download/weixin_44299969/10894786

  第四部分:https://download.csdn.net/download/weixin_44299969/10894809

  

  四、補充

  

  1.網上的教程中,有很多介紹將finereport的lib文件做成maven repository的,本人試了試,也可以操作成功,具體操作方法為:

  (1)新建一個bat文件,並將下列的語句復制進去,注意根據你的實際情況修改finereport的jar包的路徑,運行這個bat文件,finereport的jar包就會加載到maven的倉庫中 

 1 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-accumulator-10.0.jar -DgroupId=com.fine -DartifactId=fine-accumulator -Dversion=10.0 -Dpackaging=jar
 2 
 3 
 4 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-activator-10.0.jar -DgroupId=com.fine -DartifactId=fine-activator -Dversion=10.0 -Dpackaging=jar
 5 
 6 
 7 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-core-10.0.jar -DgroupId=com.fine -DartifactId=fine-core -Dversion=10.0 -Dpackaging=jar
 8 
 9 
10 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-datasource-10.0.jar -DgroupId=com.fine -DartifactId=fine-datasource -Dversion=10.0 -Dpackaging=jar
11 
12 
13 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-decision-10.0.jar -DgroupId=com.fine -DartifactId=fine-decision -Dversion=10.0 -Dpackaging=jar
14 
15 
16 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-decision-report-10.0.jar -DgroupId=com.fine -DartifactId=fine-decision-report -Dversion=10.0 -Dpackaging=jar
17 
18 
19 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-report-engine-10.0.jar -DgroupId=com.fine -DartifactId=fine-report-engine -Dversion=10.0 -Dpackaging=jar
20 
21 
22 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-schedule-10.0.jar -DgroupId=com.fine -DartifactId=fine-schedule -Dversion=10.0 -Dpackaging=jar
23 
24 
25 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-schedule-report-10.0.jar -DgroupId=com.fine -DartifactId=fine-schedule-report -Dversion=10.0 -Dpackaging=jar
26 
27 
28 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-swift-log-adaptor-10.0.jar -DgroupId=com.fine -DartifactId=fine-swift-log-adaptor -Dversion=10.0 -Dpackaging=jar
29 
30 
31 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-third-10.0.jar -DgroupId=com.fine -DartifactId=fine-third -Dversion=10.0 -Dpackaging=jar
32 
33 
34 call mvn install:install-file -Dfile=E:\programfiles\FineReport_10.0\webapps\webroot\WEB-INF\lib\fine-webui-10.0.jar -DgroupId=com.fine -DartifactId=fine-webui -Dversion=10.0 -Dpackaging=jar

  (2)在pom文件中,添加以下依賴(正文中的依賴不變)

  

 1 <dependency>
 2             <groupId>com.fine</groupId>
 3             <artifactId>fine-core</artifactId>
 4             <version>10.0</version>
 5         </dependency>
 6         <dependency>
 7             <groupId>com.fine</groupId>
 8             <artifactId>fine-activator</artifactId>
 9             <version>10.0</version>
10         </dependency>
11         <dependency>
12             <groupId>com.fine</groupId>
13             <artifactId>fine-core</artifactId>
14             <version>10.0</version>
15         </dependency>
16         <dependency>
17             <groupId>com.fine</groupId>
18             <artifactId>fine-datasource</artifactId>
19             <version>10.0</version>
20         </dependency>
21         <dependency>
22             <groupId>com.fine</groupId>
23             <artifactId>fine-decision</artifactId>
24             <version>10.0</version>
25         </dependency>
26         <dependency>
27             <groupId>com.fine</groupId>
28             <artifactId>fine-decision-report</artifactId>
29             <version>10.0</version>
30         </dependency>
31         <dependency>
32             <groupId>com.fine</groupId>
33             <artifactId>fine-report-engine</artifactId>
34             <version>10.0</version>
35         </dependency>
36         <dependency>
37             <groupId>com.fine</groupId>
38             <artifactId>fine-schedule</artifactId>
39             <version>10.0</version>
40         </dependency>
41         <dependency>
42             <groupId>com.fine</groupId>
43             <artifactId>fine-schedule-report</artifactId>
44             <version>10.0</version>
45         </dependency>
46         <dependency>
47             <groupId>com.fine</groupId>
48             <artifactId>fine-swift-log-adaptor</artifactId>
49             <version>10.0</version>
50         </dependency>
51         <dependency>
52             <groupId>com.fine</groupId>
53             <artifactId>fine-third</artifactId>
54             <version>10.0</version>
55         </dependency>
56         <dependency>
57             <groupId>com.fine</groupId>
58             <artifactId>fine-webui</artifactId>
59             <version>10.0</version>
60         </dependency>

  (3)此時,正文中第一步的過程中,可以把帆軟提供的lib文件中以fine打頭的jar包不拷貝到你的項目的webapp中

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM