Giter Site home page Giter Site logo

xutils's Introduction

背景

作为一个Java开发者,在开发的过程中,总有一些代码是经常要用到的。有些可能是一些第三方JAR,但是总有一部分是我们自己造的轮子,而且自己造的用起来也比较顺畅,这个工具类就是这么而来的,也算是自己的一个积累,开源出来,有码同享嘛。

原则

尽量不依赖任何第三方JAR。就是这么任性,不想受到别人的牵制。

lock模块

利用数据库做了一个分布式锁。支持锁超时,可重入等。当项目流量不算很大时(这个大取决于数据库可以承受多少压力,一般单库1000QPS以下,感觉压力都不算大)稳定性还是很好的。以下是简单用法:

//连库数据源,这里使用Druid
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/xxx?useUnicode=true&characterEncoding=utf8");
dataSource.setUsername("xxx");
dataSource.setPassword("xxx");
//创建分布式可重入锁并初始化,可单例使用
DbLock lock = new DbReentrantLock();
lock.init(dataSource);
//使用
try{
    //加锁,设置超时10S
    lock.tryLock("testResource", 10 * 1000);
}catch(Exception e){
    //Ignore
}finally{
    //解锁
    lock.unLock("testResource");
}

sequence模块说明

开发过需要查询数据库表功能的同学都应该知道。数据需要一个主键。如果是单表,那一般我们还可以用mysql的自增来搞定。但是到了分库分表的时候,这个就不能用了。这个模块主要就是用来解决分布式连续id生成。

mix模块说明

Cache模块

实现了一套本地缓存。

concurrent模块

对JDK自带的任务调度API进行了简单的封装。

jdbc模块

主要是对SQL语法串的拼接操作等封装。

io模块

主要是对File文件操作的api封装

http

对Java原生的URLConnection进行封装,支持GET、POST、文件下载,文件上传等

utils模块

这部分最有用个人觉得,里面是一些常用的工具类,每个工具类差不多都很独立,可以单独copy出来使用。

domain

主要是常用的domain

bt

这里放着一些奇奇怪怪的黑科技,指不定哪天你就会用到 (1)tracker 一个耗时日志打点工具,主要用来临时记录超长RT执行逻辑 (2)tabooed 一个敏感词过滤器,个人感觉好像效率不是很好,有待验证 (3)status 一个状态检查器工具,目前实现了内存使用和负载状态检查

交流群

650927052

xutils's People

Contributors

xuan698400 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xutils's Issues

关于UUIDUtils 疑问

你好,我看了你的UUIDUtils 这个类,有点不是很明白,为什么要getJVM(),getHighTime(),getCount()
我一般的习惯就是UUID.randomUUID,再替换一下"-",就拿去用了,能不能说说为什么,谢谢

关于UUIDUtils 疑问

你好,我看了你的UUIDUtils 这个类,有点不是很明白,为什么要getJVM(),getHighTime(),getCount()
我一般的习惯就是UUID.randomUUID,再替换一下"-",就拿去用了,能不能说说为什么,谢谢

同学,您这个项目引入了202个开源组件,存在118个漏洞,辛苦升级一下

检测到 xuan698400/xutils 一共引入了202个开源组件,存在118个漏洞

漏洞标题:Fastjson <=1.2.68 远程代码执行漏洞
缺陷组件:com.alibaba:[email protected]
漏洞编号:
漏洞描述:Fastjson 是Java语言实现的快速JSON解析和生成器,在<=1.2.68的版本中攻击者可通过精心构造的JSON请求,远程执行恶意代码。
漏洞原因:
Fastjson采用黑白名单的方法来防御反序列化漏洞,导致当黑客不断发掘新的反序列化Gadgets类时,发现在autoType关闭的情况下仍然可能可以绕过黑白名单防御机制,造成远程命令执行漏洞。
国家漏洞库信息:https://www.cnvd.org.cn/flaw/show/CNVD-2020-30827
影响范围:(∞, 1.2.69)
最小修复版本:1.2.69
缺陷组件引入路径:com.xuan:[email protected]>com.alibaba:[email protected]

另外还有118个漏洞,详细报告:https://mofeisec.com/jr?p=a0e1fe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.