UReport2集成SpringBoot-基础配置

UReport2集成SpringBoot-基础配置

  • 1. 引入maven依赖
  • 2. 注入UReport2 需要使用到的Servlet,并引入配置文件
  • 3. 配置application.yml
  • 4. 修改报表默认路径
  • 5. 启动SpringBoot项目

1. 引入maven依赖

<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starterartifactId>
		dependency>

		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-testartifactId>
			<scope>testscope>
		dependency>
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-webartifactId>
		dependency>
		<dependency>
			<groupId>mysqlgroupId>
			<artifactId>mysql-connector-javaartifactId>
			<version>5.1.46version>
		dependency>
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-jdbcartifactId>
		dependency>
		<dependency>
			<groupId>com.bstek.ureportgroupId>
			<artifactId>ureport2-consoleartifactId>
			<version>2.2.8version>
		dependency>

2. 注入UReport2 需要使用到的Servlet,并引入配置文件

@SpringBootApplication
@ImportResource("classpath:ureport-console-context.xml")
public class Ureport2DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(Ureport2DemoApplication.class, args);
	}

	@Bean
	public ServletRegistrationBean<UReportServlet> buildUreportServlet(){
		return new ServletRegistrationBean<UReportServlet>(new UReportServlet(), "/ureport/*");
	}
}

3. 配置application.yml

server:
  port: 8081

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false
    username: test
    password: test
    driver-class-name: com.mysql.jdbc.Driver

4. 修改报表默认路径

在resource下创建ureport.properties,文件内容如下

ureport.disableHttpSessionReportCache=true
ureport.disableFileProvider=false
ureport.fileStoreDir=d:/ureport2files
ureport.debug=true

5. 启动SpringBoot项目

访问http://localhost:8081/ureport/designer,出现如下界面则配置成功
UReport2集成SpringBoot-基础配置_第1张图片

你可能感兴趣的:(UReport2,spring,boot)