ureport2 mysql_springboot整合UReport2「建议收藏」

ureport2 mysql_springboot整合UReport2「建议收藏」###1、首先新建一个springboot项目###可以用idea直接新建,也可以在spring-boot官方提供的生成器生成项目,生成地址是:[https://start.spring.io/][https_start.spring.io]###2、配置pom.xml###org.springframework.bootspring-boot-starter-jdbcmysqlmysql…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

### 1、首先新建一个springboot项目 ###

可以用idea直接新建,也可以在spring-boot官方提供的生成器生成项目,生成地址是:[https://start.spring.io/][https_start.spring.io]

### 2、配置pom.xml ###

org.springframework.boot

spring-boot-starter-jdbc

mysql

mysql-connector-java

org.springframework.boot

spring-boot-starter-web

org.mybatis.spring.boot

mybatis-spring-boot-starter

2.1.1

com.syyai.spring.boot

ureport-spring-boot-starter

2.2.9

org.springframework.boot

spring-boot-starter-test

test

org.junit.vintage

junit-vintage-engine

### 3、配置application.yml配置文件 ###

spring:

type: com.alibaba.druid.pool.DruidDataSource

datasource:

url: jdbc:mysql://localhost:3306/ureport?useUnicode=true&characterEncoding=UTF8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai

username: root

password: 123456

driver-class-name: com.mysql.cj.jdbc.Driver

main:

allow-bean-definition-overriding: true

logback:

logPath: /ureport/log

level: INFO

server:

port: 8080

### 4、编写config代码类,用于配置UReport2 ###

import com.bstek.ureport.console.UReportServlet;

import com.bstek.ureport.definition.datasource.BuildinDatasource;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

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

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.context.annotation.ImportResource;

import javax.annotation.Resource;

import javax.sql.DataSource;

import java.sql.Connection;

import java.sql.SQLException;

@ImportResource(“classpath:ureport-console-context.xml”)//不加项目能够启动但是会导致加载数据源报错或加载不了

@Configuration

public class UreportConfig implements BuildinDatasource {

@Resource

DataSource dataSource;

private Logger log = LoggerFactory.getLogger(getClass());

@Bean //定义ureport的启动servlet

@SuppressWarnings(“unchecked”)

public ServletRegistrationBean ureportServlet(){

ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new UReportServlet());

servletRegistrationBean.addUrlMappings(“/ureport/*”);

return servletRegistrationBean;

}

@Override

public String name() {

return “myUReportDatasource”;

}

@Override

public Connection getConnection() {

try {

return dataSource.getConnection();

} catch (SQLException e) {

log.error(“Ureport 数据源 获取连接失败!”);

e.printStackTrace();

}

return null;

}

}

### 5、启动项目,打开ureport设计页面 ###

访问:http://localhost:8080/ureport/designer

即可打开报表设计页面

[https_start.spring.io]: https://start.spring.io/

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/209967.html原文链接:https://javaforall.net

(0)
上一篇 2025年7月30日 下午4:01
下一篇 2025年7月30日 下午4:43


相关推荐

  • LaTex 希腊字母对照表

    LaTex 希腊字母对照表LATEXL AT EXLATE X 希腊字母对照表显示输入显示输入 alpha alpha beta beta gamma gamma delta delta varepsilon varepsilon eta eta theta theta iota iota kappa kappa lambda lambda mu mu nu nu xi xiooo

    2026年3月17日
    1
  • python中怎么替换字符串中的内容_python怎么替换字符串的内容「建议收藏」

    python中怎么替换字符串中的内容_python怎么替换字符串的内容「建议收藏」Python中replace()函数把字符串中的old(旧字符串)替换成new(新字符串),如果指定第三个参数max,则替换不超过max次。replace()函数语法:str.replace(old,new[,max])参数:old–将被替换的子字符串。new–新字符串,用于替换old子字符串。max–可选字符串,替换不超过max次。返回值:返回字符串中的o…

    2022年5月9日
    155
  • jdbc事物描述_事物包括哪些

    jdbc事物描述_事物包括哪些数据库事务数据一旦提交,就不可回滚那些操作会导致数据的自动提交?DDL操作一旦执行,都会自动提交-. set autocommit = false不起作用DML默认情况下,一旦执行就会自动提交-. 可以设置set autocommit = false关闭连接的时候会自动提交 Connection connection = DriverManager.getConnection(url, user, password); connection.setAutoCommit

    2022年8月8日
    8
  • dropout理解「建议收藏」

    dropout理解「建议收藏」1.dropout解决的问题深度神经网络的训练是一件非常困难的事,涉及到很多因素,比如损失函数的非凸性导致的局部最优值、计算过程中的数值稳定性、训练过程中的过拟合等。过拟合是指模型训练到一定程度后,在测试集上得到的测试误差远大于在训练集上得到的误差。导致过拟合的主要原因有: 1.训练数据集太小 2.模型太复杂 3.过度训练2.dropoutdropout是指在训练一…

    2022年5月1日
    58
  • 【C++】细说C++中的数组之动态数组

    【C++】细说C++中的数组之动态数组nbsp fishing pan https blog csdn net u0 转载请注明出处 1 前言 nbsp nbsp nbsp 上周 写了一篇 细说 C 中的数组之静态数组 今天讲述一下动态数组 nbsp nbsp 数组是一种顺序存储的数据结构 在定义数组时 首先要确定数组的大小 静态数组在编译时就需要确定数组的大小 所以 为了防止内存溢出 我们尽量将数组定义的大一些 但是这样太过浪费内存

    2026年3月19日
    2
  • 初试 Windows XP Embedded 系统开发1[通俗易懂]

    初试 Windows XP Embedded 系统开发1

    2022年1月27日
    44

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号