Skip to content

Commit 04dcd07

Browse files
committed
spring boot 集成 ureport2 实现自定义报表
1 parent d709389 commit 04dcd07

File tree

13 files changed

+188
-1
lines changed

13 files changed

+188
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spring Boot Demo
22

3-
spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actuator、logback、jpa、mybatis、redis缓存、swagger模块,后续会集成activemq,email, freemarker,shiro,websocket,quartz,netty等模块。
3+
spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actuator(监控)、logback(日志)、JPA(ORM 框架)、mybatis(ORM 框架)、redis-cache(缓存)、swagger(API 接口管理测试)、ureport2(中国式报表)模块,后续会集成activemq,email, freemarker,shiro,websocket,quartz,netty等模块。
44

55
依赖的 Spring Boot 版本:
66

@@ -42,6 +42,7 @@ spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actu
4242
<module>../spring-boot-demo-mybatis</module>
4343
<module>../spring-boot-demo-cache-redis</module>
4444
<module>../spring-boot-demo-swagger</module>
45+
<module>../spring-boot-demo-ureport2</module>
4546
</modules>
4647

4748
<parent>
@@ -136,6 +137,7 @@ spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actu
136137
| [spring-boot-demo-mybatis](./spring-boot-demo-mybatis) | spring-boot 集成 [mybatis-spring-boot-starter](https://github.com/mybatis/spring-boot-starter)[mybatis-spring-boot-starter](https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter) |
137138
| [spring-boot-demo-cache-redis](./spring-boot-demo-cache-redis) | spring-boot 使用 Redis 做缓存 |
138139
| [spring-boot-demo-swagger](./spring-boot-demo-swagger) | spring-boot 集成 [spring-boot-starter-swagger](https://github.com/SpringForAll/spring-boot-starter-swagger) (由大佬[翟永超](http://blog.didispace.com/)开源)用于统一管理、测试 API 接口 |
140+
| [spring-boot-demo-ureport2](./spring-boot-demo-ureport2) | spring-boot 集成 [ureport2](https://github.com/youseries/ureport) 实现自定义报表(ureport2可以轻松实现复杂的中国式报表,功能十分强大) |
139141

140142
# 官方提供的 starter 介绍
141143

spring-boot-demo-parent/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<module>../spring-boot-demo-mybatis</module>
2121
<module>../spring-boot-demo-cache-redis</module>
2222
<module>../spring-boot-demo-swagger</module>
23+
<module>../spring-boot-demo-ureport2</module>
2324
</modules>
2425

2526
<parent>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# spring-boot-demo-ureport2
2+
3+
依赖 [spring-boot-demo-parent](../spring-boot-demo-parent)[ureport2](https://github.com/youseries/ureport) (ureport2 可以轻松实现复杂的中国式报表,功能十分强大)
4+
5+
### pom.xml
6+
7+
```xml
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>spring-boot-demo-ureport2</artifactId>
14+
<version>0.0.1-SNAPSHOT</version>
15+
<packaging>war</packaging>
16+
17+
<name>spring-boot-demo-ureport2</name>
18+
<description>Demo project for Spring Boot</description>
19+
20+
<parent>
21+
<groupId>com.xkcoding</groupId>
22+
<artifactId>spring-boot-demo-parent</artifactId>
23+
<version>0.0.1-SNAPSHOT</version>
24+
<relativePath>../spring-boot-demo-parent/pom.xml</relativePath>
25+
</parent>
26+
27+
<properties>
28+
<ureport2.version>2.2</ureport2.version>
29+
</properties>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>com.bstek.ureport</groupId>
34+
<artifactId>ureport2-console</artifactId>
35+
<version>${ureport2.version}</version>
36+
</dependency>
37+
</dependencies>
38+
39+
<build>
40+
<finalName>spring-boot-demo-ureport2</finalName>
41+
</build>
42+
43+
</project>
44+
```
45+
46+
### UReportConfiguration.java
47+
48+
```java
49+
@Configuration
50+
@ImportResource("classpath:ureport-context.xml")
51+
public class UReportConfiguration {
52+
53+
@Bean
54+
public ServletRegistrationBean initUReport() {
55+
return new ServletRegistrationBean(new UReportServlet(), "/ureport/*");
56+
}
57+
}
58+
```
59+
60+
### ureport-context.xml
61+
62+
```xml
63+
<?xml version="1.0" encoding="UTF-8"?>
64+
<beans xmlns="http://www.springframework.org/schema/beans"
65+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
67+
68+
<import resource="classpath:ureport-console-context.xml"/>
69+
70+
<bean id="propertyConfigurer" parent="ureport.props">
71+
<property name="location">
72+
<value>classpath:ureport-config.properties</value>
73+
</property>
74+
</bean>
75+
</beans>
76+
```
77+
78+
### ureport-config.properties
79+
80+
```properties
81+
# 配置模板存放的位置
82+
ureport.fileStoreDir=/Users/yangkai.shen/Documents/code/back-end/spring-boot-demo/spring-boot-demo-ureport2/src/main/resources/ureportfiles
83+
```
84+
85+
### resources目录
86+
87+
```
88+
resources
89+
├── application.yml···························spring boot 配置文件
90+
├── export····································运行 demo 示例后,导出的文件
91+
│   ├── ureport.docx··························导出的 word 文件
92+
│   ├── ureport.pdf···························导出的 PDF 文件
93+
│   └── ureport.xlsx··························导出的 Excel 文件
94+
├── ureport-config.properties·················ureport2 自定义的一些配置信息,比如模板存放路径
95+
├── ureport-context.xml·······················ureport2 的配置文件
96+
└── ureportfiles······························用于存放 ureport2 的模板文件
97+
└── ureport-demo.ureport.xml··············demo 示例的模板文件
98+
```
99+

spring-boot-demo-ureport2/pom.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<artifactId>spring-boot-demo-ureport2</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<packaging>war</packaging>
9+
10+
<name>spring-boot-demo-ureport2</name>
11+
<description>Demo project for Spring Boot</description>
12+
13+
<parent>
14+
<groupId>com.xkcoding</groupId>
15+
<artifactId>spring-boot-demo-parent</artifactId>
16+
<version>0.0.1-SNAPSHOT</version>
17+
<relativePath>../spring-boot-demo-parent/pom.xml</relativePath>
18+
</parent>
19+
20+
<properties>
21+
<ureport2.version>2.2</ureport2.version>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>com.bstek.ureport</groupId>
27+
<artifactId>ureport2-console</artifactId>
28+
<version>${ureport2.version}</version>
29+
</dependency>
30+
</dependencies>
31+
32+
<build>
33+
<finalName>spring-boot-demo-ureport2</finalName>
34+
</build>
35+
36+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.xkcoding.springbootdemoureport2;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class SpringBootDemoUreport2Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(SpringBootDemoUreport2Application.class, args);
11+
}
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
server:
2+
port: 8080
3+
context-path: /demo
111 KB
Binary file not shown.
93.5 KB
Binary file not shown.
108 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# 配置模板存放的位置
2+
ureport.fileStoreDir=/Users/yangkai.shen/Documents/code/back-end/spring-boot-demo/spring-boot-demo-ureport2/src/main/resources/ureportfiles

0 commit comments

Comments
 (0)