@@ -1,6 +1,6 @@ | |||||
# Spring Boot Demo | # Spring Boot Demo | ||||
spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actuator、logback、jpa、mybatis、redis缓存、swagger模块,后续会集成activemq,email, freemarker,shiro,websocket,quartz,netty等模块。 | |||||
spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actuator(监控)、logback(日志)、JPA(ORM 框架)、mybatis(ORM 框架)、redis-cache(缓存)、swagger(API 接口管理测试)、ureport2(中国式报表)模块,后续会集成activemq,email, freemarker,shiro,websocket,quartz,netty等模块。 | |||||
依赖的 Spring Boot 版本: | 依赖的 Spring Boot 版本: | ||||
@@ -42,6 +42,7 @@ spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actu | |||||
<module>../spring-boot-demo-mybatis</module> | <module>../spring-boot-demo-mybatis</module> | ||||
<module>../spring-boot-demo-cache-redis</module> | <module>../spring-boot-demo-cache-redis</module> | ||||
<module>../spring-boot-demo-swagger</module> | <module>../spring-boot-demo-swagger</module> | ||||
<module>../spring-boot-demo-ureport2</module> | |||||
</modules> | </modules> | ||||
<parent> | <parent> | ||||
@@ -136,6 +137,7 @@ spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actu | |||||
| [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) | | | [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) | | ||||
| [spring-boot-demo-cache-redis](./spring-boot-demo-cache-redis) | spring-boot 使用 Redis 做缓存 | | | [spring-boot-demo-cache-redis](./spring-boot-demo-cache-redis) | spring-boot 使用 Redis 做缓存 | | ||||
| [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 接口 | | | [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 接口 | | ||||
| [spring-boot-demo-ureport2](./spring-boot-demo-ureport2) | spring-boot 集成 [ureport2](https://github.com/youseries/ureport) 实现自定义报表(ureport2可以轻松实现复杂的中国式报表,功能十分强大) | | |||||
# 官方提供的 starter 介绍 | # 官方提供的 starter 介绍 | ||||
@@ -20,6 +20,7 @@ | |||||
<module>../spring-boot-demo-mybatis</module> | <module>../spring-boot-demo-mybatis</module> | ||||
<module>../spring-boot-demo-cache-redis</module> | <module>../spring-boot-demo-cache-redis</module> | ||||
<module>../spring-boot-demo-swagger</module> | <module>../spring-boot-demo-swagger</module> | ||||
<module>../spring-boot-demo-ureport2</module> | |||||
</modules> | </modules> | ||||
<parent> | <parent> | ||||
@@ -0,0 +1,99 @@ | |||||
# spring-boot-demo-ureport2 | |||||
依赖 [spring-boot-demo-parent](../spring-boot-demo-parent)、[ureport2](https://github.com/youseries/ureport) (ureport2 可以轻松实现复杂的中国式报表,功能十分强大) | |||||
### pom.xml | |||||
```xml | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<artifactId>spring-boot-demo-ureport2</artifactId> | |||||
<version>0.0.1-SNAPSHOT</version> | |||||
<packaging>war</packaging> | |||||
<name>spring-boot-demo-ureport2</name> | |||||
<description>Demo project for Spring Boot</description> | |||||
<parent> | |||||
<groupId>com.xkcoding</groupId> | |||||
<artifactId>spring-boot-demo-parent</artifactId> | |||||
<version>0.0.1-SNAPSHOT</version> | |||||
<relativePath>../spring-boot-demo-parent/pom.xml</relativePath> | |||||
</parent> | |||||
<properties> | |||||
<ureport2.version>2.2</ureport2.version> | |||||
</properties> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.bstek.ureport</groupId> | |||||
<artifactId>ureport2-console</artifactId> | |||||
<version>${ureport2.version}</version> | |||||
</dependency> | |||||
</dependencies> | |||||
<build> | |||||
<finalName>spring-boot-demo-ureport2</finalName> | |||||
</build> | |||||
</project> | |||||
``` | |||||
### UReportConfiguration.java | |||||
```java | |||||
@Configuration | |||||
@ImportResource("classpath:ureport-context.xml") | |||||
public class UReportConfiguration { | |||||
@Bean | |||||
public ServletRegistrationBean initUReport() { | |||||
return new ServletRegistrationBean(new UReportServlet(), "/ureport/*"); | |||||
} | |||||
} | |||||
``` | |||||
### ureport-context.xml | |||||
```xml | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<beans xmlns="http://www.springframework.org/schema/beans" | |||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> | |||||
<import resource="classpath:ureport-console-context.xml"/> | |||||
<bean id="propertyConfigurer" parent="ureport.props"> | |||||
<property name="location"> | |||||
<value>classpath:ureport-config.properties</value> | |||||
</property> | |||||
</bean> | |||||
</beans> | |||||
``` | |||||
### ureport-config.properties | |||||
```properties | |||||
# 配置模板存放的位置 | |||||
ureport.fileStoreDir=/Users/yangkai.shen/Documents/code/back-end/spring-boot-demo/spring-boot-demo-ureport2/src/main/resources/ureportfiles | |||||
``` | |||||
### resources目录 | |||||
``` | |||||
resources | |||||
├── application.yml···························spring boot 配置文件 | |||||
├── export····································运行 demo 示例后,导出的文件 | |||||
│ ├── ureport.docx··························导出的 word 文件 | |||||
│ ├── ureport.pdf···························导出的 PDF 文件 | |||||
│ └── ureport.xlsx··························导出的 Excel 文件 | |||||
├── ureport-config.properties·················ureport2 自定义的一些配置信息,比如模板存放路径 | |||||
├── ureport-context.xml·······················ureport2 的配置文件 | |||||
└── ureportfiles······························用于存放 ureport2 的模板文件 | |||||
└── ureport-demo.ureport.xml··············demo 示例的模板文件 | |||||
``` | |||||
@@ -0,0 +1,36 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<artifactId>spring-boot-demo-ureport2</artifactId> | |||||
<version>0.0.1-SNAPSHOT</version> | |||||
<packaging>war</packaging> | |||||
<name>spring-boot-demo-ureport2</name> | |||||
<description>Demo project for Spring Boot</description> | |||||
<parent> | |||||
<groupId>com.xkcoding</groupId> | |||||
<artifactId>spring-boot-demo-parent</artifactId> | |||||
<version>0.0.1-SNAPSHOT</version> | |||||
<relativePath>../spring-boot-demo-parent/pom.xml</relativePath> | |||||
</parent> | |||||
<properties> | |||||
<ureport2.version>2.2</ureport2.version> | |||||
</properties> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.bstek.ureport</groupId> | |||||
<artifactId>ureport2-console</artifactId> | |||||
<version>${ureport2.version}</version> | |||||
</dependency> | |||||
</dependencies> | |||||
<build> | |||||
<finalName>spring-boot-demo-ureport2</finalName> | |||||
</build> | |||||
</project> |
@@ -0,0 +1,12 @@ | |||||
package com.xkcoding.springbootdemoureport2; | |||||
import org.springframework.boot.SpringApplication; | |||||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
@SpringBootApplication | |||||
public class SpringBootDemoUreport2Application { | |||||
public static void main(String[] args) { | |||||
SpringApplication.run(SpringBootDemoUreport2Application.class, args); | |||||
} | |||||
} |
@@ -0,0 +1,3 @@ | |||||
server: | |||||
port: 8080 | |||||
context-path: /demo |
@@ -0,0 +1,2 @@ | |||||
# 配置模板存放的位置 | |||||
ureport.fileStoreDir=/Users/yangkai.shen/Documents/code/back-end/spring-boot-demo/spring-boot-demo-ureport2/src/main/resources/ureportfiles |
@@ -0,0 +1,13 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<beans xmlns="http://www.springframework.org/schema/beans" | |||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> | |||||
<import resource="classpath:ureport-console-context.xml"/> | |||||
<bean id="propertyConfigurer" parent="ureport.props"> | |||||
<property name="location"> | |||||
<value>classpath:ureport-config.properties</value> | |||||
</property> | |||||
</bean> | |||||
</beans> |
@@ -0,0 +1,16 @@ | |||||
package com.xkcoding.springbootdemoureport2; | |||||
import org.junit.Test; | |||||
import org.junit.runner.RunWith; | |||||
import org.springframework.boot.test.context.SpringBootTest; | |||||
import org.springframework.test.context.junit4.SpringRunner; | |||||
@RunWith(SpringRunner.class) | |||||
@SpringBootTest | |||||
public class SpringBootDemoUreport2ApplicationTests { | |||||
@Test | |||||
public void contextLoads() { | |||||
} | |||||
} |