zoukankan      html  css  js  c++  java
  • ureport2 + spring boot 搭建

    ureport2使用

    ureport2

    UReport2是一款基于架构在Spring之上纯Java的高性能报表引擎,通过迭代单元格可以实现任意复杂的中国式报表

    在UReport2中,提供了全新的基于网页的报表设计器,可以在Chrome、Firefox、Edge等各种主流浏览器运行(IE浏览器除外)。使用UReport2,打开浏览器即可完成各种复杂报表的设计制作。

    一、搭建ureport2

    1. 搭建maven项目(目前用idea搭建,spring boot框架)
    2. 在pom.xml中添加先关依赖
    (1) Ureport2的相关依赖代码

     <dependencies>标签下添加ureport2依赖

    <dependency>

    <groupId>com.bstek.ureport</groupId>

    <artifactId>ureport2-console</artifactId>

    <version>[version]</version>

    </dependency>

    (2) 链接数据库的相关依赖(MySQL)(只搭建ureport2可以不添加数据库)

     <dependencies>标签下添加 MySQL依赖

    <dependency>

    <groupId>commons-dbcp</groupId>

    <artifactId>commons-dbcp</artifactId>

    <version>[version]</version>

    </dependency>

    <dependency>

    <groupId>mysql</groupId>

    <artifactId>mysql-connector-java</artifactId>

    <version>[version]</version>

    </dependency>

    (3) Spring boot 相关依赖(可要可不要,也可以搭建在web工程下)

     <dependencies>标签下添加springboot依赖

    <dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-web</artifactId>

    </dependency>

     <project>标签下添加springboot依赖

    <parent>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-parent</artifactId>

    <version>[version]</version>

    </parent>

    1. 在src/main/resources 下创建 application.properties 文件
    (1) 配置数据库链接

    ## 更改 ureport2 的保存目录(需真实存在的目录)

    # ureport.fileStoreDir=G:/tool/ureportfiles

    ##

    ## 如若不需要更改:

    ## 1.web项目:默认在项目webweb-infureportfiles

    ## 2.spring boot项目:

    ##   C:Users用户名AppDataLocalTemp omcat-docbase.??.8080WEB-INFureportfiles

    # 数据库链接 数据源配置

    spring.datasource.url=jdbc:mysql://localhost:3306/ag_auth

    spring.datasource.username=root

    spring.datasource.password=123456

    spring.datasource.driverClassName=com.mysql.jdbc.Driver

    1. 在src/main/resources 下创建 context.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:application.properties</value>

            </property>

        </bean>

    </beans>

    1. 在src/main/java下创建 com.bstek.ureport.test package
    2. 在com.bstek.ureport.test包下创建Application.java 文件

    package com.bstek.ureport.test;

    import com.bstek.ureport.console.UReportServlet;

    import org.springframework.boot.SpringApplication;

    import org.springframework.boot.autoconfigure.SpringBootApplication;

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

    import org.springframework.context.annotation.Bean;

    import org.springframework.context.annotation.ImportResource;

    /**

     * 加载对应的xml配置文件

     */

    @ImportResource("classpath:context.xml")

    /** 指定类为应用启动类 */

    @SpringBootApplication

    public class Application {

        /**

         * main 函数

         */

        public static void main(String[] args) {

            /** main方法中通过SpringApplicationrun方法启动应用。 */

            SpringApplication.run(Application.class, args);

        }

        /**

         * 进行注册Servlet

         * 配置 UReport2 需要使用到的servlet

         */

        @Bean

        public ServletRegistrationBean buildUReportServlet() {

            /**

             * @param  servlet

             * @param  urlMappings 值为“/ureport/*”的 urlMappings 是一定不能变的,否则系统将无法运行。

             */

            return new ServletRegistrationBean(new UReportServlet(), "/ureport/*");

        }

    }

    二、运行main()

    1. 点击Application.java 文件 → 右键 → 点击(run’Application.main()’)

     

    三、验收结果

    1. 在浏览器输入地址

    http://localhost:8080/ureport/designer

    1. 效果图

     

     

  • 相关阅读:
    SSIM (Structural Similarity) 结构相似性
    倒字八板-中国敲击乐系列-大得胜(晋北鼓乐)
    中国绝不称霸、中国永远不称霸-汇总
    Spring Cloud简介
    bat脚本的基本命令语法
    Spring Boot源码中模块详解
    http statusCode(状态码)请求URL返回状态值的含义
    ActiveMQ消息中间件的作用以及应用场景
    Windows7 64位配置ODBC数据源(Sybase)的方法
    python3 selenium模块Chrome设置代理ip的实现
  • 原文地址:https://www.cnblogs.com/Seven-cjy/p/9542616.html
Copyright © 2011-2022 走看看