Integrated related support for Spring Boot projects

Overview

Table of Contents

xyz-support

介绍

对Spring Boot项目进行相关统合的支持

引入

确保当前仓库有该包,暂未录入公共仓库,自行放入。

<dependency>
    <groupId>com.xyz</groupId>
    <artifactId>xyz-support</artifactId>
    <version>1.0.0</version>
</dependency>

当前引用Spring Boot版本

2.1.3.RELEASE

当前引用外部依赖的版本

  • 谷歌guava:28.0-jre
  • 谷歌gson:2.8.5
  • 七牛云sdk:7.7.0
  • okhttp:3.14.2
  • commons-net:3.4
  • commons-io:2.11.0
  • poi:3.9

提示:maven仓库方式引用的话,上述外部依赖的版本若与本地不一致,以自身情况考量并存还是存其一; 若以普通jar本地引入,请注意引入上述依赖。或可对源码进行修改后运行无误后进行打包使用。

当前已支持的服务

文件(对象存储)服务

  • 本地存储已支持
  • Ftp存储已支持
  • 七牛云存储已支持
  • ...

文档服务

  • excel服务
    • 使用poi(支持xls和xlsx操作)
  • ...

手册

文件(对象存储)服务

配置

注意:目前只支持Spring Boot的配置方式,即application.properties(application.yml), 讲解将以application.properties进行(application.yml同理)。

# 文件服务的启动标志 true/false
xyz.support.file.enable=true

# local文件服务配置 list形式 严格从0下标递增,否则不识别,application.yml中直接-替代(推荐)
xyz.support.file.local...
# 举例local
# local服务名 必传(没有服务名配啥呢)
xyz.support.file.local[0].serviceName=xxx
# local指定的根路径 必传
xyz.support.file.local[0].localPath=xxx


# ftp文件服务配置 list形式 严格从0下标递增,否则不识别,application.yml中直接-替代(推荐)
xyz.support.file.ftp...
# 举例ftp
# ftp服务名 必传
xyz.support.file.ftp[0].serviceName=xxx
# ftp指定的host 不传默认为127.0.0.1
xyz.support.file.ftp[0].host=127.0.0.1
# ftp指定的port 不传默认为21
xyz.support.file.ftp[0].port=21
# ftp指定的timeout 不传默认为5000
xyz.support.file.ftp[0].timeout=5000
# ftp指定的username 必传
xyz.support.file.ftp[0].username=xxx
# ftp指定的password 必传
xyz.support.file.ftp[0].password=xxx


# 七牛云文件服务配置 list形式 严格从0下标递增,否则不识别,application.yml中直接-替代(推荐)
xyz.support.file.qiniu...
# 举例七牛云
# 七牛云服务名 必传
xyz.support.file.qiniu[0].serviceName=xxx
# 七牛云accessKey 必传
xyz.support.file.qiniu[0].accessKey=xxx
# 七牛云secretKey 必传
xyz.support.file.qiniu[0].secretKey=xxx
# 七牛云bucket(空间名) 必传
xyz.support.file.qiniu[0].bucket=xxx
# 七牛云domain(访问域名) 必传
xyz.support.file.qiniu[0].domain=xxx
# 七牛云publicFlag(空间公开标志 true/false) 默认为false
xyz.support.file.qiniu[0].publicFlag=false

使用例子

假定进行了如下配置,以application.yml形式:

xyz:
  support:
    file:
      enable: true
      local:
        - serviceName: localFileService
          localPath: /localFile

若要对服务进行调用,业务服务中(按正常注入bean的方式即可):

@Resource
private FileInterface localFileService;

api介绍

更详细的解释见FileInterface

method description
String upload(File file) File的方式上传,文件名取本名,文件路径在当前服务根路径
String upload(File file, String fileName) File的方式上传,文件名取自定义,文件路径在当前服务根路径
String upload(File file, String fileName, String filePath) File的方式上传,文件名取自定义,文件路径也取自定义(相对于当前服务根路径)
String upload(MultipartFile file) MultipartFile的方式上传,文件名取本名,文件路径在当前服务根路径
String upload(MultipartFile file, String fileName) MultipartFile的方式上传,文件名取自定义,文件路径在当前服务根路径
String upload(MultipartFile file, String fileName, String filePath) MultipartFile的方式上传,文件名取自定义,文件路径也取自定义(相对于当前服务根路径)
String upload(InputStream is, String fileName) 流的方式上传,文件名取自定义,文件路径在当前服务根路径
String upload(InputStream is, String fileName, String filePath) 流的方式上传,文件名取自定义,文件路径也取自定义(相对于当前服务根路径)
File download(String fileName, String filePath) 文件下载,提供File
byte[] download(String fileName) 文件下载,提供字节数组

文档服务

excel服务

提供的服务包含解析excel成对象导出对象成excel,支持常规性的excel内容识别(标准的一行行数据,不要出现隐藏行,使用时请注意),支持常规类型数据的导出(包括Date,专属注解支持)。

配置

注意:目前只支持Spring Boot的配置方式,即application.properties(application.yml), 讲解将以application.properties进行(application.yml同理)。

# excel服务的启动标志 true/false
xyz.support.document.excel.enable=true

# excel服务bean配置 list形式 严格从0下标递增,否则不识别,application.yml中直接-替代(推荐)
xyz.support.document.excel.bean...
# 服务名 必传
xyz.support.document.excel.bean[0].serviceName=xxx
# 服务的类型  poi、custom 除了custom自定义,其他类型将选用默认的对应实现 不传默认为poi,但不能传错
xyz.support.document.excel.bean[0].type=poi
# 自定义服务的全限定类名 type选custom时需指定(若无法加载,将会报错)
xyz.support.document.excel.bean[0].clazz=xxx
使用例子

假定进行了如下配置,以application.yml形式:

xyz:
  support:
    document:
      excel:
        enable: true
        bean:
          - serviceName: excelService
            type: custom
            clazz: com.xyz.support.document.excel.poi.DefaultPoiExcelOperation

若要对服务进行调用,业务服务中(按正常注入bean的方式即可):

@Resource
private ExcelOperation excelService;

api介绍

更详细的解释见ExcelOperation

method description
List parse(File file, Class resultType) 解析excel到对应bean,忽略第一行数据(认为是头)
List parse(File file, boolean filterFirstRow, Class resultType) 解析excel到对应bean,忽不忽略第一行由调用方决定
List parse(MultiFile file, Class resultType) 解析excel(MultipartFile)到对应bean,忽略第一行数据(认为是头)
List parse(MultiFile file, boolean filterFirstRow, Class resultType) 解析excel(MultipartFile)到对应bean,忽不忽略第一行由调用方决定
void export(File target, Class dataType, List dataList) 导出数据生成excel,数据按bean并由对应规则解析出来,导出到本地文件
void export(HttpServletResponse response, String fileName, Class dataType, List dataList) 导出数据生成excel,数据按bean并由对应规则解析出来,通过网络导出
void export(File target, SheetItem sheetItem) 导出数据生成excel,数据通过通用赋值对象传递,导出到本地文件
void export(HttpServletResponse response, String fileName, SheetItem sheetItem) 导出数据生成excel,数据通过通用赋值对象传递,通过网络导出
You might also like...

Two Spring-boot applications registering themselves to an spring-boot-admin-server application as separate clients for the purpose of monitoring and managing the clients

Two Spring-boot applications registering themselves to an spring-boot-admin-server application as separate clients for the purpose of monitoring and managing the clients

Spring-boot-admin implementation with 1 Server and 2 clients Creating a Server application to monitor and manage Spring boot applications (clients) un

Oct 8, 2021

The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker.

gke-springboot-sampleapp 👋 The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker. Usage To be

Feb 1, 2022

Spring Boot Migrator (SBM) - a tool for automated code migrations to upgrade or migrate to Spring Boot

Spring Boot Migrator (SBM) - a tool for automated code migrations to upgrade or migrate to Spring Boot

Spring Boot Migrator uses and is compatible to OpenRewrite, a powerful mass refactoring ecosystem for Java and other source code.

Sep 30, 2022

All development related with the ONLYONE token.

onlyone All development related with the Onlyone Finance. ONLYONE Token Total Supply: 1 Contract creation: https://bscscan.com/tx/0x1becbd78297f267dec

Sep 3, 2022

Scan and patch tool for CVE-2021-44228 and related log4j concerns.

A Log4J2 CVE-2021-44228 Vulnerability Scanner and Patcher Links to download the latest version: Linux x64 with glibc2.17+ (RHEL7+) Windows & all other

Jun 1, 2022

QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties

QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties

QuickPerf is a testing library for Java to quickly evaluate and improve some performance-related properties quickperf.io 📙 Documentation Annotations

Sep 23, 2022

This repository is related to the Java Web Developer (ND035), Course - Web Services and APIs

About this Repository This repository is related to the Java Web Developer (ND035), Course - Web Services and APIs It contains the following folders:

Jan 28, 2022

This repository contains Java programs to become zero to hero in Java. Programs related to each and every concep are present from easy to intermidiate level.

Learn Java Programming In this repository you will find topic wise programs of java from basics to intermediate. This follows topic wise approach that

Sep 25, 2022

Hi, Spring fans! In this installment we look Spring Integration's support for MQTT and the HiveMQ broker

Spring Integration MQTT & HiveMQ Hi, Spring fans! In this installment we look Spring Integration's support for MQTT and the HiveMQ broker. I'm joined

Feb 4, 2022
Owner
xiaoyezi
xiaoyezi
该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的线上博客项目/企业大型商城系统/前后端分离实践项目等,摆脱各种 hello world 入门案例的束缚,真正的掌握 Spring Boot 开发。

Spring Boot Projects 该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的前

十三 4.4k Sep 25, 2022
循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

mrbird 24.3k Sep 27, 2022
A Fully Code Integrated Dynamic DataBase Management System for the Java Platform

dynamic-database A fully code integrated minimal database management system for Java, Scala, Kotlin or Groovy projects. It is written in Java and can

omega ui 2 Jun 8, 2022
A simple live streaming mobile app with cool functionalities and time extension, and live chat. With a payment system integrated. Server is designed with socket.io to give you full flexibility.

Video Live Streaming Platform Android A simple live streaming mobile app with cool functionalities and time extension, and live chat. With a payment s

Dev-Geek 1 Oct 16, 2021
Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example

Spring Boot Login example with Spring Security, MySQL and JWT Appropriate Flow for User Login and Registration with JWT Spring Boot Rest Api Architect

null 40 Sep 30, 2022
Tuya 34 Sep 7, 2022
100+ Spring Boot Articles, Tutorials, Video tutorials, Projects, Guides, Source code examples etc

YouTube Channel - Spring Boot Tutorial Subscribe for future video and updates Spring Boot Tutorial on YouTube Newly published spring boot tutorials (2

Ramesh Fadatare 1.1k Sep 26, 2022
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

Spring Boot 学习示例 Spring Boot 使用的各种示例,以最简单、最实用为标准,此开源项目中的每个示例都以最小依赖,最简单为标准,帮助初学者快速掌握 Spring Boot 各组件的使用。 Spring Boot 中文索引 | Spring Cloud学习示例代码 | Spring

纯洁的微笑 28.1k Oct 2, 2022
spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。另外写博客,用 OpenWrite。

推荐工具: 微信公众号 Markdown 编辑器 - OpenWrite:Markdown 微信编辑器是一款专业强大的微信公众平台在线编辑排版工具,提供手机预览功能,让用户在微信图文 、文章、内容排版、文本编辑、素材编辑上更加方便。 - 更多介绍 博客群发平台 一、支持泥瓦匠 Spring Boot

泥瓦匠BYSocket 15.1k Sep 30, 2022
Spring-Boot-Plus is a easy-to-use, high-speed, high-efficient,feature-rich, open source spring boot scaffolding

Everyone can develop projects independently, quickly and efficiently! What is spring-boot-plus? A easy-to-use, high-speed, high-efficient, feature-ric

geekidea 2.2k Oct 1, 2022