一、maven構(gòu)建項目
1、訪問http://start.spring.io/
2、選擇構(gòu)建工具M(jìn)aven Project、Spring Boot版本2.0.5以及一些工程基本信息,點(diǎn)擊“Switch to the full version.”java版本選擇8,可參考下圖所示:
3、點(diǎn)擊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文件中默認(rèn)有兩個模塊:
spring-boot-starter:核心模塊,包括自動配置支持、日志和YAML;
spring-boot-starter-test:測試模塊,包括JUnit、Hamcrest、Mockito。
2、編寫controller內(nèi)容
@RestController
public class HelloWorldController {
? ? @RequestMapping("/hello")
? ? public String index() {
? ? ? ? return "Hello World";
? ? }
}
@RestController的意思就是controller里面的方法都以json格式輸出,不用再寫什么jackjson配置的了!
3、啟動主程序,打開瀏覽器訪問http://localhost:8080/hello,就可以看到效果了,有木有很簡單!
三、皕杰web應(yīng)用嵌套springboot項目
1、在springboot項目src/main文件夾下創(chuàng)建webapp目錄
2、將皕杰報表demoserver/webapps/report下的bios_demo、bios_jsp、bios_web_res、WEB-INF文件夾復(fù)制到springboot項目src/main/webapp下
3、更改springboot項目的pom.xml
在〈dependencies〉〈/dependencies〉節(jié)點(diǎn)里添加
〈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〉節(jié)點(diǎn)里添加
〈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/圖文展現(xiàn)/動態(tài)色彩.brt