惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
V
V2EX
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
小众软件
小众软件
Vercel News
Vercel News
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
J
Java Code Geeks
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog
B
Blog
美团技术团队
量子位

博客园 - 正怒月神

windows 安装 openclaw docker-compose 启动 elk linux mysql 备份 maven 打包时优先选择本地仓库 nginx 部署2个相同的vue minio 设置IP MapStruct-plus cannot find converter from jenkins pipeline 发布 jar并运行 MapperStruct 嵌套模型中 List<> 转 List<String> Easy es问题总结 Logstash docker发布 Docker 无法拉取 springmvc 多事务提交和回滚 java 通过 microsoft graph 调用outlook(三) JPA Example 默认 join jackson.dataformat.xml 反序列化 对象中包含泛型 OR-TOOL 背包算法 解决JIRA、Confluence自动注销登录的问题 java 通过 microsoft graph 调用outlook(二)
springMvc 配置 UReport2
正怒月神 · 2024-06-05 · via 博客园 - 正怒月神

参考:https://blog.csdn.net/qq_42207808/article/details/112258835

1.配置pom.xml

引入目前最新得2.2.9版本

            <dependency>
                <groupId>com.bstek.ureport</groupId>
                <artifactId>ureport2-console</artifactId>
                <version>2.2.9</version>
            </dependency>

2.web.xml配置

<!-- ureport2接口 -->
<servlet>
    <servlet-name>ureportServlet</servlet-name>
    <servlet-class>com.bstek.ureport.console.UReportServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ureportServlet</servlet-name>
    <url-pattern>/ureport/*</url-pattern>
</servlet-mapping>
 

3.spring-context.xml配置(这里我配置在了application.xml中)

mvc直接引入ureport xml配置即可,并引入配置文件,如果有properties就用现在得,没有就新建

<!--引入ureport2-->
<import resource="classpath*:ureport-console-context.xml" />
<bean id="propertyConfigurer" parent="ureport.props">
    <property name="location" value="classpath:/properties/dangjian.properties"/>
</bean>

4.properties配置

#ureport固定配置(fileStoreDir默认为tomact启动下得WEB-INF下面得ureportfiles文件夹,可以自定义路径ureport.fileStoreDir=E:/work/ureportfiles)
ureport.fileStoreDir=ureportfiles
ureport.disableHttpSessionReportCache=false
ureport.disableFileProvider=false
ureport.debug=true

5.新建类实现BuildinDatasource接口,用以配置项目内置数据源

package com.jeeplus.modules.ureport;
 
import com.alibaba.druid.pool.DruidDataSource;
import com.bstek.ureport.definition.datasource.BuildinDatasource;
import com.jeeplus.common.utils.SpringContextHolder;
import org.springframework.stereotype.Component;
 
import java.sql.Connection;
import java.sql.SQLException;
 
/**
 * 内置数据源
 * @author jsy
 * @version 2021/1/4
 **/
@Component
public class ReportDateSource implements BuildinDatasource {
 
    private DruidDataSource druid = SpringContextHolder.getBean(DruidDataSource.class);
 
    @Override
    public String name() {
 
        return "mysql_druid";
    }
 
    @Override
    public Connection getConnection() {
 
        try {
            return druid.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
 

6.启动项目访问(关于URL下述的URL

http://localhost:9006/ureport/designer 中,需要根据项目情况修改9006端口

注:报表设计器表达式校验依赖于Antlr4,表达式报错得话请pom引入Antlr4

<dependency>
    <groupId>org.antlr</groupId>
    <artifactId>antlr4-runtime</artifactId>
    <version>4.9.1</version>
</dependency>