皕杰报表集成到springboot项目 2018-10-12

简介: 一、maven构建项目1、访问http://start.spring.io/2、选择构建工具Maven Project、Spring Boot版本2.

一、maven构建项目

1、访问http://start.spring.io/

2、选择构建工具Maven Project、Spring Boot版本2.0.5以及一些工程基本信息,点击“Switch to the full version.”java版本选择8,可参考下图所示:

img_68f813382f7b79b2743182ab8e310aa6.png

3、点击Generate Project下载项目压缩包

4、解压后,使用eclipse,Import -〉 Existing Maven Projects -〉 Next -〉选择解压后的文件夹-〉 Finsh,OK done!

二、引入web模块

1、pom.xml中添加支持web的模块:

〈dependency〉、

      〈groupId〉org.springframework.boot〈/groupId〉

      〈artifactId〉spring-boot-starter-web〈/artifactId〉

 〈/dependency〉

pom.xml文件中默认有两个模块:

spring-boot-starter:核心模块,包括自动配置支持、日志和YAML;

spring-boot-starter-test:测试模块,包括JUnit、Hamcrest、Mockito。

2、编写controller内容

@RestController

public class HelloWorldController {

    @RequestMapping("/hello")

    public String index() {

        return "Hello World";

    }

}

@RestController的意思就是controller里面的方法都以json格式输出,不用再写什么jackjson配置的了!

3、启动主程序,打开浏览器访问http://localhost:8080/hello,就可以看到效果了,有木有很简单!

三、皕杰web应用嵌套springboot项目

1、在springboot项目src/main文件夹下创建webapp目录

img_ec78ce665a2f4119262fe338053212e2.png

2、将皕杰报表demoserver/webapps/report下的bios_demo、bios_jsp、bios_web_res、WEB-INF文件夹复制到springboot项目src/main/webapp下

img_1d81c456029d0afe3325090f5a995ee4.png

3、更改springboot项目的pom.xml

在〈dependencies〉〈/dependencies〉节点里添加

〈dependency〉

〈groupId〉org.springframework.boot〈/groupId〉

〈artifactId〉spring-boot-devtools〈/artifactId〉

〈optional〉true〈/optional〉

〈/dependency〉

〈dependency〉

〈groupId〉javax.servlet〈/groupId〉

〈artifactId〉jstl〈/artifactId〉

〈/dependency〉

〈dependency〉  

〈groupId〉bijet-license〈/groupId〉 

〈artifactId〉bijet-license-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bijet-license.jar〈/systemPath〉  

〈/dependency〉

〈dependency〉  

〈groupId〉bios-cos〈/groupId〉  

〈artifactId〉bios-cos-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bios-cos.jar〈/systemPath〉  

〈/dependency〉

〈dependency〉  

〈groupId〉bios-cos〈/groupId〉  

〈artifactId〉bios-cos-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bios-cos.jar〈/systemPath〉  

〈/dependency〉

〈dependency〉  

〈groupId〉bios-ehcache-1.6.2〈/groupId〉  

〈artifactId〉bios-ehcache-1.6.2-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bios-ehcache-1.6.2.jar〈/systemPath〉  

〈/dependency〉

〈dependency〉  

〈groupId〉bios-iText-2.1.7〈/groupId〉  

〈artifactId〉bios-iText-2.1.7-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bios-iText-2.1.7.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉bios-poi-3.9〈/groupId〉  

〈artifactId〉bios-poi-3.9-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bios-poi-3.9.jar〈/systemPath〉  

〈/dependency〉  

〈dependency〉  

〈groupId〉bios-poi-ooxml-3.9〈/groupId〉  

〈artifactId〉bios-poi-ooxml-3.9-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bios-poi-ooxml-3.9.jar〈/systemPath〉  

〈/dependency〉  

〈dependency〉  

〈groupId〉bios-report〈/groupId〉  

〈artifactId〉bios-report-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/bios-report.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉dom4j-1.6.1〈/groupId〉  

〈artifactId〉dom4j-1.6.1-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/dom4j-1.6.1.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉commons-logging-1.0.4〈/groupId〉  

〈artifactId〉commons-logging-1.0.4-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/commons-logging-1.0.4.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉iTextAsian〈/groupId〉  

〈artifactId〉iTextAsian-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/iTextAsian.jar〈/systemPath〉  

〈/dependency〉

〈dependency〉  

〈groupId〉javax.wsdl_1.5.1.v200806030408〈/groupId〉  

〈artifactId〉javax.wsdl_1.5.1.v200806030408-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/javax.wsdl_1.5.1.v200806030408.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉javax.xml_1.3.4.v200902170245〈/groupId〉  

〈artifactId〉javax.xml_1.3.4.v200902170245-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/javax.xml_1.3.4.v200902170245.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉org.apache.xerces_2.9.0.v200909240008〈/groupId〉  

〈artifactId〉org.apache.xerces_2.9.0.v200909240008-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/org.apache.xerces_2.9.0.v200909240008.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉poi-ooxml-schemas-3.9-20121203〈/groupId〉  

〈artifactId〉poi-ooxml-schemas-3.9-20121203-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/poi-ooxml-schemas-3.9-20121203.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉stax-api-1.0.1〈/groupId〉  

〈artifactId〉stax-api-1.0.1-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/stax-api-1.0.1.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉xmlbeans-2.3.0〈/groupId〉  

〈artifactId〉xmlbeans-2.3.0-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/xmlbeans-2.3.0.jar〈/systemPath〉  

〈/dependency〉 

〈dependency〉  

〈groupId〉server〈/groupId〉  

〈artifactId〉server-sdk〈/artifactId〉  

〈version〉1.0〈/version〉  

〈scope〉system〈/scope〉  

〈systemPath〉${basedir}/src/main/webapp/WEB-INF/lib/server.jar〈/systemPath〉  

〈/dependency〉


在〈build〉〈/build〉节点里添加

〈resources〉

〈resource〉

〈directory〉src/main/webapp/WEB-INF/resources〈/directory〉

〈includes〉

〈include〉**/*.properties〈/include〉

〈include〉**/*.yml〈/include〉

〈include〉**/*.xml〈/include〉

〈include〉**/*.tld〈/include〉


〈/includes〉

〈filtering〉false〈/filtering〉

〈/resource〉

〈/resources〉

4、新建reportConfig类配置皕杰报表servlet访问

package com.example.demo;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.boot.context.properties.ConfigurationProperties;

import org.springframework.boot.web.servlet.*;

import org.springframework.context.annotation.*;

import bios.report.engine.output.*;

@Configuration 

public class reportConfig {

@Bean

public ServletRegistrationBean servletRegistrationBean() {

ServletRegistrationBean re = new ServletRegistrationBean(new ReportEmitter());

re.setLoadOnStartup(2);

re.setName("reportServlet");

re.addInitParameter("reportConf", "config.xml");

re.addUrlMappings("/ReportEmitter");

return re;

}

public ServletRegistrationBean servletRegistrationBean1() {

ServletRegistrationBean re = new ServletRegistrationBean(new ImageServlet());

re.setName("imageServlet");

re.addUrlMappings("/ImgServlet");

return re;

}

public ServletRegistrationBean servletRegistrationBean2() {

ServletRegistrationBean re = new ServletRegistrationBean(new FillinServlet());

re.setName("fillinServlet");

re.addUrlMappings("/FillinServlet");

return re;

}

}

5、启动springboot项目,访问报表

http://localhost:8080/ReportEmitter?rpt=Demo/图文展现/动态色彩.brt

img_4263c67b6c850b6f602bf25d7e1913d0.png
目录
相关文章
|
18天前
|
消息中间件 Java Kafka
Springboot集成高低版本kafka
Springboot集成高低版本kafka
|
24天前
|
NoSQL Java Redis
SpringBoot集成Redis解决表单重复提交接口幂等(亲测可用)
SpringBoot集成Redis解决表单重复提交接口幂等(亲测可用)
275 0
|
29天前
|
NoSQL Java Redis
SpringBoot集成Redis
SpringBoot集成Redis
417 0
|
1月前
|
NoSQL Java Redis
小白版的springboot中集成mqtt服务(超级无敌详细),实现不了掐我头!!!
小白版的springboot中集成mqtt服务(超级无敌详细),实现不了掐我头!!!
272 1
|
1天前
|
Java Docker 容器
SpringBoot项目集成XXL-job
SpringBoot项目集成XXL-job
|
3天前
|
Java 关系型数据库 数据库
【SpringBoot系列】微服务集成Flyway
【4月更文挑战第7天】SpringBoot微服务集成Flyway
【SpringBoot系列】微服务集成Flyway
|
18天前
|
SQL Java 调度
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
|
25天前
|
NoSQL Java Redis
SpringBoot集成Redis
SpringBoot集成Redis
54 1
|
29天前
|
Java 测试技术 Maven
SpringBoot集成Elasticsearch
SpringBoot集成Elasticsearch
24 0