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...

Spring-Boot-Plus is a easy-to-use, high-speed, high-efficient,feature-rich, open source spring boot scaffolding

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

Dec 31, 2022

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

Dec 6, 2022

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.

Jan 2, 2023

一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024

一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024

友情提示:因为提供了 50000+ 行示例代码,所以艿艿默认注释了所有 Maven Module。 胖友可以根据自己的需要,修改 pom.xml 即可。 一个涵盖六个主流技术栈的正经仓库: 《Spring Boot 专栏》 《Spring Cloud Alibaba 专栏》 《Spring Clou

Dec 31, 2022

参考 DDD/Clean Architecture 设计理念,整合 Spring Boot/Spring Security/Mybatis Plus/Vavr 的 Spring Realworld 应用案例

参考 DDD/Clean Architecture 设计理念,整合 Spring Boot/Spring Security/Mybatis Plus/Vavr 的 Spring Realworld 应用案例

Demo · 更多项目 · 参考资料 ms-spring-ddd-examples Unified Domain-driven Layered Architecture for MicroService Apps,试图探索一套切实可行的应用架构规范,可以复制、可以理解、可以落地、可以控制复杂性的指导

Sep 23, 2022

Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Tutorial for Beginners File Directory Apache Tomcat Apache Tomcat - Eclipse Bağlantısı Spring Paketlerinin İndirilmesi ve Projeye Entegrasyonu

Apr 11, 2022

Spring Boot JdbcTemplate example with SQL Server: CRUD Rest API using Spring Data JDBC, Spring Web MVC

Spring Boot JdbcTemplate example with SQL Server: Build CRUD Rest API Build a Spring Boot CRUD Rest API example that uses Spring Data Jdbc to make CRU

Dec 20, 2022

Spring Boot & MongoDB Login and Registration example with JWT, Spring Security, Spring Data MongoDB

Spring Boot & MongoDB Login and Registration example with JWT, Spring Security, Spring Data MongoDB

Spring Boot Login and Registration example with MongoDB Build a Spring Boot Auth with HttpOnly Cookie, JWT, Spring Security and Spring Data MongoDB. Y

Dec 30, 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.5k Dec 30, 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.8k Jan 6, 2023
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 58 Jan 5, 2023
Tuya 37 Dec 26, 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.2k Jan 2, 2023
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 2 Dec 16, 2022
DataCap is integrated software for data transformation, integration and visualization.

DataCap (incubator) DataCap is integrated software for data transformation, integration and visualization. Require Must-read for users: Be sure to exe

EdurtIO 184 Dec 28, 2022
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

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

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

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

泥瓦匠BYSocket 15.2k Jan 5, 2023