54 Star 366 Fork 98

yl-yue / yue-library

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
Apache-2.0

一个基于SpringBoot封装的增强库

yue-library官网 yue-library JavaDoc Maven Central with version prefix filter GitHub Spring%20Boot Version Spring%20Cloud Version gitee star GitHub Repo stars GitHub issues

-- 主页:https://ylyue.cn/ --

-- QQ群:883630899 --


介绍

  yue-library是一个基于SpringBoot封装的增强库,提供丰富的Java工具类库、优越的ORM框架、优雅的业务封装、优化的Spring环境配置、完善的规约限制、配套的代码生成平台、安稳贴切的开源架构方案等,只为打造更好的JavaWeb开发环境,提升大家的开发质量与效率,降低企业研发成本。

  适用于企业快速构建属于自己的切合架构,不为技术负累,不盲目跟风,不原地踏步,从单体与集群分布式与微服务,企业结合自身业务所处阶段,灵活选择逐步跟进升级。

工程结构

在多模块打包时,为加快构建速度并增强模块独立维护性,部分模块在未迭代且兼容的情况下,不再随主版本一起发布

. yue-library
├── yue-library                       yue-library顶级模块
│   ├── yue-library-base                  基础核心模块,提供丰富的Java工具类库、接口参数校验、类型转换器等
│   ├── yue-library-base-crypto           加解密模块,提供对称、非对称和摘要算法、密钥交换加解密等
│   ├── yue-library-web                   WebMvc模块,servlet编程,提供请求与响应参数的包装与解析等
│   ├── yue-library-webflux               WebFlux模块,响应式编程(如:SpringCloudGateway)
│   └── yue-library-data-mybatis          ORM框架,基于mybatis-plus,拥有着强大性能的同时又不失简单灵活等
│   ├── yue-library-data-redis            Redis客户端,基于SpringRedis,更简单灵活,提供分布式锁等
│   ├── yue-library-data-es               Elasticsearch Rest与SQL客户端(兼容OpenSearch),提供安全认证等属性配置
│   ├── yue-library-auth-service          OAuth2认证模块,基于SpringSecurity,更简单灵活,提供全局token与登录等
│   ├── yue-library-auth-client           OAuth2客户端模块,提供获取当前登录用户状态信息等
│   └── yue-library-pay                   支付模块,基于pay-java-parent,让你真正做到一行代码实现支付聚合
└── yue-library-samples               yue-library示例项目
    ├── yue-library-test                  web测试项目,提供详细的特性使用示例、接口单元测试
    ├── yue-library-test-webflux          webflux测试项目,提供详细的特性使用示例、接口单元测试
    ├── yue-library-template-boot         SpringBoot项目模版,提供快速开发示例
    └── yue-library-template-cloud        SpringCloud项目模版,SOA共享架构(阿里巴巴中台)

快速开始

引入项目依赖

maven项目,在pom.xml文件中添加如下一段代码,并将${version}替换为对应版本号:Maven Central with version prefix filter

<parent>
	<groupId>ai.ylyue</groupId>
	<artifactId>yue-library</artifactId>
	<version>${version}</version>
</parent>

随后引入所需要的模块,如WebMvc项目引入:yue-library-web

依赖说明:yue-library-base为基础模块,一般情况下不需要单独引入,如:web、data-mybatis、data-redis等模块皆已默认依赖。

<dependencies>
	<dependency>
		<groupId>ai.ylyue</groupId>
		<artifactId>yue-library-web</artifactId>
	</dependency>
	...
</dependencies>

启动项目

新建一个SpringBoot main方法启动类:

@SpringBootApplication
public class TestApplication {

	public static void main(String[] args) throws Exception {
		SpringApplication.run(TestApplication.class, args);
	}

}

写一个测试接口:

@RestController
@RequestMapping("/quickstart")
public class QuickstartController {

	@GetMapping("/get")
	public Result<?> get(JSONObject paramJson) {
		return R.success(paramJson);
	}
	
}

访问接口测试,如:http://localhost:8080/quickstart/get

{
    "code": 200,
    "msg": "成功",
    "flag": true,
    "traceId": "a1bde0ba625de731",
    "data": {}
}

上述代码完全保持了SpringBoot的风格,但又使用到了yue-library的增强特性,如:

  • HTTP消息转换器支持使用Alibaba Fastjson作为参数接收对象
  • 请求参数智能解析,无需再为URL query-string、Body from-data、Body application/json传参方式烦恼
  • 错误时会对异常进行统一处理,响应RESTful风格的错误提示
  • 支持前端跨域请求

当然除了这些已使用到的特性之外,你还可以尝试如:响应时间类型时自动格式化、请求参数校验、API接口版本控制、反复读取Servlet输入流等。 并且在yue-library-samples目录下,存放着不同架构类型的示例模板,你可以根据自身需求选择,从而快速上手。

核心模块说明

yue-library-base(必备)

  base模块提供了丰富的Java工具类库,它能够帮助我们简化每一行代码(增强Hutool工具包)。
  同时提供优越的Spring本土化环境配置,可在 application.yml 文件中配置关闭,所有配置项皆是以yue.*开头,如:yue.cors.allow=false代表不允许跨域。

  • 丰富的Java基础工具类,对文件、流、加密解密、转码、正则、线程、XML等JDK方法进行封装
  • 完善的RESTful支持,使用HTTP响应包装对象Result,友好返回接口响应内容
  • 完善的异常处理机制,支持I18n、规范打印、安全拦截敏感错误响应,异常提示简单易懂
  • 出色的服务端校验框架validator,支持多种校验方式,简单易用,校验规则丰富,更贴切国内校验场景
  • 强大的类型转换器Convert,优越的性能,超强的容错能力,妈妈再也不用担心我找不到好用的“BeanUtils”了
  • 安全的异步线程池,完美解决子线程上下文环境问题,就算是高并发下,异步执行任务时再也不丢失token等参数了
  • 优雅的密钥交换加密,安全高效的解决HTTP通信传输安全
  • 简洁完善的Java全局网络代理,轻松解决内网部署时的网络代理需求

yue-library-web/webflux(必备)

  web/webflux模块提供友好的JavaWeb开发环境,免去本土化烦恼,提供友好的默认配置,解决开发中常遇的槽点,提升大家的开发质量与效率,降低企业研发成本。

  • 美妙愉悦的开发体验,让跨域、热加载、时间格式、参数获取等,低级而又普遍存在的问题都见鬼去吧
  • 强大的HTTP请求参数解析器,解决参数获取困扰,Request请求参数智能解析,让前后端联调和平相处
  • 强大的HTTP响应消息转换器,优雅实现固定类型参数格式化、NULL值处理等,轻松收到来至前端同事的致谢
  • 强大的HTTP请求包装器,解决Servlet输入流被前置的某个拦截器读取一空,导致请求参数获取不到
  • 强大的ServletUtils,让我们在任何时候任何地方,对接口的请求参数与响应内容都能为所欲为
  • 优雅的接口版本控制@ApiVersion,再也不用担心团队成员对接口规范视若无睹为所欲为了

yue-library-data-mybatis(强烈推荐)

  data-mybatis模块基于Mybatis-Plus封装的ORM框架,拥有着强大性能的同时又不失简单灵活,特性如下:

  • 强大易用:比MyBatis更方便好用、比SpringJpa更简单灵活、比SpringJdbc更健壮完善
  • 无侵入:data-mybatis在Mybatis-Plus的基础上进行扩展,只做增强不做改变,简化CRUD等操作
  • 依赖管理:引入即可启动项目,关联druid实现SQL全监控
  • 预防Sql注入:内置Sql注入剥离器,有效预防Sql注入攻击
  • 损耗小:封装大量经过SQL优化处理的CRUD方法,直接面向对象操作,对比原生级CRUD处理,性能基本无损甚至更优
  • 通用CRUD操作:内置通用DAO,通过继承方式即可实现单表大部分CRUD操作
  • 更科学的分页:分页参数统一处理,无多线程忧虑,自由拼接更通用,无分页性能忧虑,更有优化型分页SQL检查
  • 内置性能分析插件:可输出Sql语句以及其执行时间,建议开发测试时启用该功能,能有效解决慢查询
  • 类型强化:支持原生级SQL查询,并强化原生查询结果,简单便捷+可维护组合(支持全Json或全Entity)
  • CRUD校验:CRUD操作是否符合预期,更好的避免脏数据的产生与违规操作
  • 数据审计:敏感操作全覆盖,简单实现对数据变动的审计需求
  • 数据填充:只需简单的配置即可实现字段默认值填充需求,新增与修改时数据自动填充
  • 数据脱敏:只需简单的配置即可实现对数据脱敏存储需求,操作时自动加解密
  • 多租户:完善的多租户方案与规范的框架支持,从容应对多租户需求,数据源SaaS隔离简单规范化
  • 全局异常处理:CRUD操作相关异常统一处理,定位更精准,提示更友好,实现全局RESTful风格

更多模块

  关于data-redisdata-esauth-serviceauth-client等模块的特性介绍与更详细的使用说明,请查看中文文档

社区

  在Gitter的社区里可以找到yue-library的用户和开发者团队。

参与贡献

欢迎各路好汉一起来参与完善 yue-library,我们期待你的 PR!

  • 贡献代码:代码地址 yue-library ,欢迎提交 Issue 或者 Pull Requests
  1. Fork本仓库并从master分支创建你的分支
  2. 如果你添加的代码需要测试,请添加测试,确保单元测试通过(测试代码请放在:yue-library-test中)
  3. 如果你修改了API,请更新文档
  4. 确保代码风格一致
  5. 提交代码
  6. 新建Pull Request
  7. 等待维护者合并
  • 维护文档:文档地址 yue-library-doc ,欢迎参与翻译和修订

PR遵照原则

yue-library欢迎你的加入,进行开源共建,提交的pr(pull request)需符合如下规范:

  • 关于注释:提供完备的注释,尤其对每个新增的方法应按照Java文档规范标明方法说明、参数说明、返回值说明等信息,亦可加上署名,必要时请添加单元测试
  • 关于缩进:采用IDEA中默认的空格作为标准,可设置一个tab四个空格
  • 关于三方库:新加的方法不要使用第三方库的方法,yue-library遵循无依赖原则

特别鸣谢

logo-jetbrains       logo-spring-tools-4
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2019 yl-yue Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

yue-library是一个基于SpringBoot封装的增强库,提供丰富的Java工具类库、优越的ORM框架、优雅的业务封装、优化的Spring环境配置、完善的规约限制、配套的代码生成平台 expand collapse
Java and 3 more languages
Apache-2.0
Cancel

Releases (18)

All

Contributors

All

Activities

Load More
can not load any more
Java
1
https://gitee.com/yl-yue/yue-library.git
git@gitee.com:yl-yue/yue-library.git
yl-yue
yue-library
yue-library
master

Search

53164aa7 5694891 3bd8fe86 5694891