1 Star 0 Fork 176

laoding / sanri-tools-maven

forked from sanri1993 / sanri-tools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

9420 开发工具包


sanri-tools-maven 是一个开源的用于企业开发的工具包,重点想解决项目开发中一些比较麻烦的问题

目前已经提供一些常用的工具,读者也可以开发自己的工具注册进来 ,欢迎 pr 或者提 issue

博客地址: https://www.cnblogs.com/sanri1993/


工具理念

  1. 轻量级,只依赖于文件系统,无权限管理
  2. 多模块,可插拨设计,只加载想要的工具
  3. 做数据监控和数据的可视化工具,不像别的工具,这个可以直接看到数据明文,而不是乱码

已经有的工具,分模块展示

  1. tools-core
    • 类加载管理 上传类 zip , class, java 文件到类加载器
    • 连接管理 创建 zookeeper, redis , database 等连接
    • 文件管理 系统的临时文件和配置文件的管理,提供临时文件下载功能
    • 插件管理 插件注册,提供给前端可访问的插件,做了一个监控指标,根据插件点击次数和最后访问时间来排序插件
    • 数据管理 可以给 class 随机生成数据,使用正则表达式生成数据,和爬网站数据功能
  2. tools-serializable
    • 提供序列化,反序列化等基础功能
  3. tools-zookeeper
    • zookeeper 连接的子节点,acl权限,节点数据,节点元数据,删除节点,写入数据
    • 路径收藏功能,方便下次直接查找
  4. tools-redis
    • 支持集群,主从和单机,展示节点主机,端口,角色,父节点; 集群可以展示槽位分配
    • key 列表查询,可以查询集群所有节点,hashKey 列表查询,key 的长度,ttl , type 展示
    • 查询某个 key 的数据,可以根据序列化和类加载器展示成友好的方式,支持(string,hash,list,set,zset)
    • 在线求 set 类型的数据交集,并集,差集
    • 监控每一个节点使用的内存信息
    • 监控每一个节点的连接数,主机占用连接数信息,杀掉某个连接
  5. tools-kafka
    • 消费组列表,删除消费组,消费组消费的主题列表,消费组消费主题某分区消费数据情况,消费组消费主题某分区附近的数据
    • 主题列表,主题尾部数据,创建主题,删除主题,模拟数据发送
    • 主题数据实时监控,brokers 列表
    • 所有的数据消费或监控都可以使用序列化配合类加载器来展示数据明文
    • JMX 监控,详情见类 BrokerTopicMetrics
  6. tools-database
    • 数据库元数据 catalog,schema,表,列,索引,主键 查询和搜索
    • 扩展元数据 表类型(字典表,配置表,业务表),表关联关系设置,展示和搜索
    • 数据库文档生成和下载
    • 使用模板生成代码,组合模板成方案生成代码
    • 使用 sql 预览数据库数据和 excel 导出,导入 excel 数据 ,表随机数据生成
    • nacos,diamond 等依赖于数据库的配置数据可以直接展示
    • 强大的搜索功能,可以使用表名,列名,注释,表标记,schema 来搜索表
    • 随机数据插入,在压力测试时可以用 , 可以用 spring 表达式,正则,关联另一张表来随机生成表数据
  7. tools-mybatis
    • 上传 mapper 文件,配合类加载器,可以找到所有的 mapper 文件中的所有 statementId
    • 根据 statementId 可以知道当前 statementId 所必传的参数
    • 传入必传参数,和数据库连接,可以直接调用 statementId, 得到 sql 语句 ,这里的数据库连接引用数据库模块的连接名
  8. tools-swagger-doc
    • 将 swagger 的文档生成更美观的文档并提供下载文档
  9. tools-dubbo
    • 依赖于 zookeeper 模块,得到 dubbo 的提供者,获取提供的方法,并可以执行调用
  10. tools-name
    • 想要给某个方法取名,但一下子想不到合适的名字,可以用这个工具帮你取名
    • 支持设置业务词,ik 分词,英语翻译
  11. tools-soap
    • 支持 soap 调用
  12. tools-websocket
    • 主要是给其它模块提供前端推送数据功能

每一个模块的使用文档

对于一个工具来说,使用文档是比较重要的,我们约定使用文档全部放到每个模块的 resources 中,取名规则为 模块名_readme.md 文件,

在模块注册的时候,我会去读取你这个文件并显示到你的模块说明文档中,你可以在 md 文件中做外链,以便链接外部说明文档

工具模块间依赖关系,扩展自己的工具时可能需要用到

tools-core
 |- tools-serializable
 
tools-zookeeper
 |- tools-core

tools-kafka 
 |- tools-zookeeper
 |- tools-websocket
  
tools-dubbo
 |- tools-zookeeper
 
tools-redis
 |- tools-core
   
tools-database
 |- tools-core

tools-swagger-doc
 |- tools-core

tools-mybatis 
 |- tools-database

tools-name
 |- tools-core
 
tools-soap
 |- tools-core

如何运行

方式一下载源码启动

  • issue 因为 tools-name 模块中的 ik 分词在中央仓库是没有的,所以你如果不需要这个模块,可以直接删除此模块, 或者你想要这个模块可以安装 ik 分词依赖,包和安装脚本都在 tools-name/src/main/resources 中

解决 ik 分词问题后,就可以直接运行 tools-console 中的 com.sanri.tools.Application 启动 ,标准的 springboot 项目

方式二下载 release 启动

https://gitee.com/sanri/sanri-tools-maven/releases

@since 2.0.0 java -jar sanritools.jar

2.0.0 版本之前,下载的 release 为 tomcat ,双击 bin/start.bat 启动

如何查看当前正在开发的工具版本

当前工具的版本在 tools-console/src/main/resources/version 文件中, 各模块的版本后面会写在 pluginDto 中注册进来

如何扩展自己的工具

新增一个模块,如 tools-xxx ,然后依赖于 tools-core

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>tools-core</artifactId>
    <version>${project.version}</version>
</dependency>

最后将模块使用插件管理注册进来

@Autowired
private PluginManager pluginManager;

@PostConstruct
public void register(){
    pluginManager.register(PluginDto.builder().module("tools-xxx").name("main").build());
}

module 在前端是做为一级菜单,然后 name 是二级菜单 , 同一个模块下可以注册多个功能项

关于单元测试

工具使用了更方便的单元测试,直接发送 http 请求来测试,所有的单元测试都在 requests/全部 http 请求.http 中

关于项目前端

官方前端 https://gitee.com/sanri/sanritoolsvue

前端美图 https://gitee.com/sanri/sanri-tools-maven/issues/I1UEJR

如果对这个前端不满意,可以使用接口进行自定义开发, 本项目只是提供数据服务

界面美图

数据库的文档生成

数据库文档生成,每个公司要求的模板都不一样,可以自己扩展,使用 jdbcService 可以拿到你想要的元数据,然后想怎么生成,全靠你自己, 我这里提供了三个示例

  • 生成 markdown 的 ,使用 database-doc.md.ftl 模板
  • 生成 html 的,使用 database-doc.html.ftl 模板
  • 生成 excel 的,实现类在 MetadataControllerShow.generate() 方法中

代码生成的元数据结构

做为一个sanri工具最早提供的功能,这个功能在网上有很多类似的实现,基本可以分为两类,一类是直接帮你生成固定的模式,只适应于它的项目模板,一类是提供使用模板生成的方式 这两种方式各有利弊,为了省事,一般使用直接生成可用的代码,如果需要二次开发最好是使用模板生成,这里我两种都有提供

尽管我已经提供了相当多的模板,但还是有需要自定义模板代码生成的用户,不可能全部穷尽,这里我把可以给到模板中的元数据结构,模板目前只支持 freemarker

  1. 通用数据,不管是 javaBean、模板代码、还是项目构建都会有这个数据
author      : 当前作者,取计算机名 
date        : 当前日期 yyyy-MM-dd 
time        : 当前时间 HH:mm:ss
  1. javaBean 构建时数据
bean        : 当前表对应的 java 实体类信息 ,引用类 JavaBeanInfo
beanConfig  : bean 的配置信息,引用类 JavaBeanBuildConfig
table       : 表元数据信息,引用类 TableMetaData
  1. 模板代码生成(每一个模板都是针对单张表的生成)
bean        : 当前表对应的 java 实体类信息 ,引用类 JavaBeanInfo
table       : 表元数据信息,引用类 TableMetaData
codeConfig  : 如果是模板代码生成 ,引用 CodeGeneratorParam
  1. 项目构建数据
tables      : 表元数据信息,引用类 TableMetaData:List
beans       : 当前表对应的 java 实体类信息 ,引用类 JavaBeanInfo:List
config      : 如果是项目构建,引用 CodeGeneratorConfig
dataSource  : 数据源,引用类 ConnectionMetaData

如何交流、反馈、参与贡献?

  • Git仓库:https://gitee.com/sanri/sanri-tools-maven
  • 官方前端:https://gitee.com/sanri/sanritoolsvue
  • 技术讨论、二次开发等咨询、问题和建议,请移步到微信群,我会在第一时间进行解答和回复
  • 如需关注项目最新动态,请Watch、Star项目,同时也是对项目最好的支持
  • 微信扫码并关注我,获得项目最新动态及更新提醒,拉你进入微信技术群
  • 如果有需要支持的中间件,可以提交 pr , 或者微信联系我

我的微信

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: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) 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 (d) 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 [yyyy] [name of copyright owner] 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.

简介

sanri-tools-maven 是一个开源的用于企业开发的工具包,重点是要解决实际开发中一些数据查询,监控 ,可视化工具,目前已经聚合了 kafka,redis,zookeeper,dubbo,swagger,soap,mybatis 的数据查询和监控,欢迎大家使用 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/joenie_ding/sanri-tools-maven.git
git@gitee.com:joenie_ding/sanri-tools-maven.git
joenie_ding
sanri-tools-maven
sanri-tools-maven
springboot

搜索帮助