1:IO的过程 当我们调用系统函数read时,一般会经历两个阶段: 1:等待数据准备(waiting for the data be ready) 2:将数组从内核拷贝到进程(从内核态到用户态)(copying the data from the kernel to the process) 在"等 Read More
posted @ 2019-11-15 17:29 李斯特王 Views(703) Comments(0) Diggs(0) Edit
AbstractQueuedSynchronizer是JUC包下的一个重要的类,JUC下的关于锁相关的类(如:ReentrantLock)等大部分是以此为基础实现的。那么我们就来分析一下AQS的原理。 1:通过以前的了解,我们先明白几个有用信息。 1:实现基于FIFO(一个先进先出的队列) 2:通过 Read More
posted @ 2019-11-07 16:45 李斯特王 Views(232) Comments(0) Diggs(0) Edit
接着我们上次说的SpringBoot自动加载原理。我们大概明白了在maven中引入mybatis后,这个模块是如下加载的。 可能会有人问了,一般我们的dao层都是通过Mapper接口+Mapper.xml的方式来操作数据库的,但是@Mapper注解并不是SpringBoot自带的注解,为什么加上@M Read More
posted @ 2019-10-24 14:56 李斯特王 Views(1631) Comments(0) Diggs(0) Edit
昨天在新建Springboot启动后,发现执行相关的SQL报错 org.apache.ibatis.binding.BindingException: Invalid bound statement,具体报错信息如下: 1 org.apache.ibatis.binding.BindingExcep Read More
posted @ 2019-10-23 11:50 李斯特王 Views(2898) Comments(2) Diggs(2) Edit
我们经常会被问到这么一个问题:SpringBoot相对于spring有哪些优势呢?其中有一条答案就是SpringBoot自动注入。那么自动注入的原理是什么呢?我们进行如下分析。 1:首先我们分析项目的启动类时,发现都会加上@SpringBootApplication这个注解,我们分析这个继续进入这个 Read More
posted @ 2019-10-17 18:43 李斯特王 Views(2111) Comments(0) Diggs(0) Edit
前些天,运维告诉我刚上线的java服务占用CPU过高。 以下是发现解决问题的具体流程。 1:通过#top命令查看,我的java服务确实把CPU几乎占满了,如图 可看到18400这个进程CPU占用达到了1200%,这确实不太正常,那么我们接下来分析到底哪些线程占用了CPU 2:通过#top -Hp 1 Read More
posted @ 2019-10-16 18:17 李斯特王 Views(678) Comments(3) Diggs(4) Edit
我们的服务使用的是springcloud,出现问题的流程大概架构是,message_producer->kafka->message_consumer->elasticsearch。 我们是一个电商项目,服务里会产生各种商品更新的消息,如价格更新,品类更新等。这些消息通过kafka被专门处理商品更新 Read More
posted @ 2019-09-19 18:37 李斯特王 Views(240) Comments(0) Diggs(1) Edit
1:为什么会出现Atomic类 在多线程或者并发环境中,我们常常会遇到这种情况 int i=0; i++ 稍有经验的同学都知道这种写法是线程不安全的。为了达到线程安全的目的,我们通常会用synchronized来修饰对应的代码块。现在我们有了新的方法,就是使用J.U.C包下的atomic类。 2:A Read More
posted @ 2019-06-17 18:04 李斯特王 Views(6922) Comments(0) Diggs(3) Edit
我们来分析SpringApplication启动流程中的run()方法,代码如下 看起来方法比较长,不过我们主要看启动流程,哪些监控,失败分析的我们以后再说,所以这个方法中关键的几步如下 没错,看到关键的方法就是这4个,我们首先分析 createApplicationContext()方法,代码如下 Read More
posted @ 2019-05-23 18:06 李斯特王 Views(214) Comments(0) Diggs(0) Edit
通过分析我们可以找到 org.springframework.boot.SpringApplication 中如下, 可以看出,SpringBoot的启动分两步 1:实例化一个SpringApplication对象 2:run 初始化的方法如下: 通过上面的代码我们可以看出,getSpringFac Read More
posted @ 2019-03-26 14:58 李斯特王 Views(248) Comments(0) Diggs(0) Edit