Spring
文章平均质量分 74
分析Spring源码。
一枚方糖
你的梦想有多远、你就能走多远✨
展开
-
『墨菲安全』10 分钟对心爱的 GitLab 代码仓库来一次全量体检
文章目录方案调研方案一(放弃)方案二(成功)脚本流程增量检测GitLab 配置项目地址去年 log4j 漏洞爆发时候就已经很痛苦了,当时把所有的线上服务排查了一遍。没想到这都已经过去3个月了,上周又遇到了一个服务仍在使用低版本,被外部攻击,有点受伤。这件事后,老板让我全量扫一遍我们的代码库,看还有哪些服务还在用老版本的 log4j,统一推一波修复,防止后续在发生此类事件。方案调研方案一(放弃)当时我第一反应是写个脚本,遍历所有项目,再拉取项目到本地,通过正则匹配的方式识别代码中是否使用了 log原创 2022-04-01 15:28:34 · 3412 阅读 · 2 评论 -
『Redis』常见应用问题 - 分布式锁
文章目录一、分布式锁1.1 问题描述1.2 Redis 实现分布式锁一、分布式锁1.1 问题描述分布式系统中多线程、多进程分配在不同的机器上,使得单机并发锁策略失效。单纯的 Java API 不能提供分布式锁的能力。需要一种跨 JVM 互斥机制来控制共享资源的访问。分布式锁主流方案:数据库缓存 (性能最高)Zookeeper (可靠性最高)1.2 Redis 实现分布式锁1、设置锁和过期时间set age 18 nx ex 60当设置 age 后,其他线程来了只能等待锁释放原创 2022-03-02 20:04:43 · 805 阅读 · 0 评论 -
『Redis』常见应用问题 - 缓存穿透、击穿、雪崩
文章目录一、缓存穿透1.1 概念1.2 具体表现1.3 解决方案二、缓存击穿2.1 概念2.2 具体表现2.3 解决方案三、缓存雪崩3.1 概念3.2 具体表现3.3 解决方案一、缓存穿透1.1 概念在 Redis 中查询不到数据,大量请求直达数据库,导致数据库宕机。1.2 具体表现应用服务器压力过大Redis 命中率降低一直查询数据库1.3 解决方案空值缓存查询数据为空(不管数据存不存在),对空结果(null)缓存并设置过期时间。白名单bitmaps 定义一个白名单,id原创 2022-03-02 17:59:00 · 367 阅读 · 0 评论 -
『Redis』 事务和锁机制
文章目录一、事务1.1 Multi、Exec、Discard1.2 事务错误处理1.3 事务冲突(乐观锁、悲观锁)1.4 事务三特性1.5 模拟秒杀案例1.5.1 超售、超时问题一、事务Redis 事务是隔离操作,所有命令都会序列化 、顺序执行,不会被其他客户端发送的命令打断。主要作用:串联多个命令,防止插队。1.1 Multi、Exec、Discard首先输入 Multi 命令开启事务,所有命令都会进入队列且不执行(组队阶段),直到输入 Exec 后命令依次执行(运行阶段)。组队阶段可通过 d原创 2022-03-02 17:10:02 · 906 阅读 · 0 评论 -
『脚手架』方糖工具箱 | 一款采用 SpringCloud 微服务架构的脚手架
文章目录????欢迎 Fork 和 Star????SugarTools????如何部署????️包含组件????正在开发中????贡献代码的步骤????欢迎 Fork 和 Star项目地址:https://github.com/xingly-cn/SugarTools请您小手点个Star。????SugarTools方糖工具箱,一款采用 SpringCloud 微服务架构的小巧工具箱,遵循不重复造轮子的原则,每个模块相互独立可直接实现到自己的项目中。目前很多功能处于开发中,有 Bug 或不去原创 2022-02-06 00:20:25 · 20859 阅读 · 0 评论 -
『玩转 Es 引擎』Elasticsearch 入门
文章目录RESTFul 访问索引操作文档操作查询操作Java API 访问环境配置RESTFul 访问索引操作一切操作遵从 RESTFul 风格。1、创建索引发送 PUT 请求:http://127.0.0.1:9200/索引名称2、查看索引指定:发送 GET 请求:http://127.0.0.1:9200/索引名称全部:发送 GET 请求:http://127.0.0.1:9200/_cat/indices?v3、删除索引发送 DELETE 请求:http://127.0.0.1:9原创 2022-01-09 19:28:14 · 1184 阅读 · 0 评论 -
『Bug记录』 SpringBoot 如何连接腾讯 Es 服务器 [IOException]
文章目录问题溯源问题排查问题溯源最近需要使用 ES 服务器,就买了一台。根据开发文档描述,发现咋都连接失败。package com.sugar.es;import org.apache.http.HttpHost;import org.apache.http.auth.AuthScope;import org.apache.http.auth.Credentials;import org.apache.http.auth.UsernamePasswordCredentials;impor原创 2022-01-08 23:02:12 · 1377 阅读 · 0 评论 -
『玩转 Netty』Netty 模型
文章目录三、Netty3.1 原生 NIO 存在的问题3.2 线程模型3.3 Netty 模型3.4 入门实例3.5 taskQueue 自定义任务3.6 异步模型原理3.7 HTTP 服务案例3.8 Netty 核心模块3.9 Pipline 组件3.10 进阶实例3.11 心跳检测3.12 WebSocket 长连接三、Netty3.1 原生 NIO 存在的问题1、NIO 库和 API 复杂,使用麻烦。2、需要具备 Java 多线程,网络编程能力。3、开发工总量大,难度大;断线重连,网络拥塞控原创 2021-12-31 12:23:19 · 810 阅读 · 0 评论 -
Java 任务调度框架 Quartz
文章目录1、Quartz1.1 引入依赖1.2 入门案例1.3 Job 与 JobDetail1.4 JobExecutionContext1.5 JobDataMap1.6 Job 状态1.7 Trigger1.8 SimpleTripper1、Quartz1.1 引入依赖<dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifac原创 2021-12-13 23:44:07 · 872 阅读 · 0 评论 -
Spring AOP——Spring 中面向切面编程
文章目录一、AOP——另一种编程思想1.1 什么是 AOP1.2 为什么需要 AOP1.3 AOP 实现分类二、AOP 术语三、初步认识 Spring AOP3.1 Spring AOP 的特点3.2 Spring AOP 的简单例子四、通过注解配置 Spring AOP4.1 通过注解声明切点指示器4.2 通过注解声明 5 种通知类型4.3 通过注解声明切点表达式4.4 通过注解处理通知中的参数4.5 通过注解配置织入的方式六、总结前几天学习 《Spring实战》 这本书,记录一下 Spring 中的原创 2021-12-01 23:30:17 · 2350 阅读 · 0 评论 -
Spring Bean对象注入静态变量
文章目录问题解决办法问题如果直接把 Bean 对象注入到静态变量会报空指针。 @Autowired private static JedisPool jedisPool;解决办法且在工具类中加上 @Component 注解。 private static JedisPool jedisPool; @Autowired public void setJedisPool(JedisPool jedisPool) { JedisUtil.jedisPool = j原创 2021-11-26 19:44:53 · 1028 阅读 · 0 评论