- 博客(41)
- 收藏
- 关注
原创 applyMergedBeanDefinitionPostProcessors
CommonAnnotationBeanPostProcessor 会:扫描方法上是否有@PostConstruct @PreDestroy注解扫描方法和属性上是否有@Resource注解注意,@Resource @PostConstruct @PreDestroy 是 JDK 的注解AutowiredAnnotationBeanPostProcessor 会:扫描方法和属性上是否有@Autowired @Value注解注意,@Autowired @Value 是 Spring 的注解扫描
2021-06-07 21:15:22
454
1
原创 CommonAnnotationBeanPostProcessor
setInitAnnotationType setDestroyAnnotationType
2021-06-07 11:30:04
215
原创 @lookup解决单例引用原型问题
package com.example.springboottest.config;import com.example.springboottest.bean.MyBean;import org.springframework.beans.factory.annotation.Lookup;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Config.
2021-06-04 16:44:16
275
原创 RequestContextHolder.getRequestAttributes()为空与hystrix关系
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();对于被hystrix注解的controller方法,其线程与其对应切面线程不一致,导致attributes为空2021-02-25/15:17:46.422 logback [http-nio-8000-exec-3] INFO c.y.kjcxweb.aop.RateLim...
2021-02-26 10:50:46
561
原创 通过Environment,获取属性
@Autowiredprivate Environment env;String url = env.getProperty("client.barcodeDist.url");String appKey = env.getProperty("client.barcodeDist.appkey");对应application.properties文件中定义的属性# 条码分配请求配置client.barcodeDist.url=http://ordercenter-es.yundas.
2021-02-26 10:46:55
1501
原创 新建本地项目提交到gitlab流程
git initgit remote add origin http://gitlab.xxx.com:8090/userid/waybill-web-auth2.gitgit add .git commit -m "程序源代码"git push -u origin master切换远程分支git checkout-b devgit pull origin dev
2021-02-25 11:52:55
238
原创 注解以及对应的处理器
@Configuration,@Bean,@PropertySource,@ComponentScan,@Import,@ImportResource ----------------------ConfigurationClassPostProcessor@ConfigurationProperties--------------ConfigurationPropertiesBindingPostProcessor
2021-01-27 09:42:57
180
1
原创 utf8编码
UTF-8UTF-8以字节为单位对Unicode进行编码。从Unicode到UTF-8的编码方式如下: Unicode编码(十六进制) UTF-8 字节流(二进制) 000000-00007F 0xxxxxxx 000080-0007FF 110xxxxx 10xxxxxx 000800-00FFFF 1110xxxx 10xxxxxx 10xxx
2020-12-22 14:07:04
665
1
原创 FactoryBean 与ObjectFactory
二者很相似,但也略有区别。通过接口内容来看,两者都是属于工厂模式用来创建对象使用的。/** * Defines a factory which can return an Object instance * (possibly shared or independent) when invoked. * * <p>This interface is typically used to encapsulate a generic factory which * returns a
2020-12-16 09:47:59
236
原创 spring容器启动过程1
创建applicationContext的方式有多种,自己new一个【实现类也不止一种】,springboot启动会自己注册一个,根据包路径中是否包含servlet等判别条件【springboot创建不同applicationcontext的判别条件】,创建的applicationContext略有区别,加载过程有很多相似的地方,本文以AnnotationConfigServletWebServerApplicationContext为例,核心代码如下:/** * Create a new {@l
2020-12-15 15:59:49
101
原创 springboot启动的applicationContext的类型选择
首先,一共有三种类型AnnotationConfigServletWebServerApplicationContext,AnnotationConfigReactiveWebServerApplicationContext,AnnotationConfigApplicationContext。springboot会根据webApplicationType的值来确定你加载哪一个applicationContext/** * Strategy method used to create t.
2020-12-15 14:48:55
1567
原创 spring源码分析----@Bean如何解析的
ConfigurationClassBeanDefinitionReader的loadBeanDefinitionsForConfigurationClass方法
2020-12-11 18:04:23
315
原创 spring源码分析----DefaultAopProxyFactory
DefaultAopProxyFactory.java/* * Copyright 2002-2015 the original author or authors. * * 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 t.
2020-12-11 14:56:21
168
原创 spring源码分析-----ProxyConfig
public class ProxyConfig implements Serializable { // 如果该值为true,则proxyFactory将会使用CGLIB对目标对象进行代理,默认值为false private boolean proxyTargetClass = false; // 标记是否对代理进行优化。启动优化通常意味着在代理对象被创建后,增强的修改将不会生效,因此默认值为false。 private boolean optim...
2020-12-11 14:50:43
205
原创 spring源码解析-----AbstractAutoProxyCreator
AbstractAutoProxyCreator.java部分代码如下以下部分代码展示了动态代理的形成过程【部分】/** * Create a proxy with the configured interceptors if the bean is * identified as one to proxy by the subclass. * @see #getAdvicesAndAdvisorsForBean */ @Override public Object p...
2020-12-11 14:38:27
337
原创 spring源码解析----AbstractAutowireCapableBeanFactory类applyBeanPostProcessorsAfterInitialization
AbstractAutowireCapableBeanFactory.java部分代码如下 //对bean应用后置处理器中的postProcessAfterInitialization方法 @Override public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName) throws BeansException { Object resul.
2020-12-11 14:35:43
461
原创 spring源码解析--------ApplicationContextAwareProcessor和ApplicationContextAware
ApplicationContextAwareProcessor.javapackage org.springframework.context.support;import java.security.AccessControlContext;import java.security.AccessController;import java.security.PrivilegedAction;import org.springframework.beans.BeansExcept...
2020-12-09 16:28:50
422
原创 spring源码解析-------AbstractApplicationContext类的prepareBeanFactory方法
源码解析AbstractApplicationContext类的protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory)方法/** * Configure the factory's standard context characteristics, * such as the context's ClassLoader and post-processors. * @param b...
2020-12-09 13:19:07
236
1
原创 java常用小工具总结
mapstruct-------------实体属性转化工具 【可对比BeanUtils】如下是这个插件的开源项目地址和各种例子:Github地址:https://github.com/mapstruct/mapstruct/ 使用例子:https://github.com/mapstruct/mapstruct-examples...
2020-12-04 11:06:18
113
原创 Git pull 问题 :fatal: refusing to merge unrelated histories
Git :fatal: refusing to merge unrelated histories解决今天本地创建了一个仓库(有README),把本地仓库和Github上关联以后,发现git pull,git feach提醒fatal: refusing to merge unrelated histories上网查到原因是两个分支是两个不同的版本,具有不同的提交历史加一句$git pull origin master --allow-unrelated-histories可..
2020-12-02 13:52:28
105
原创 偶遇错误503 and 500
Error 503--Service Unavailable From RFC 2068Hypertext Transfer Protocol -- HTTP/1.1: 10.5.4 503 Service Unavailable The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. Th...
2020-12-02 10:16:07
1204
原创 轮询算法
线程安全的轮询算法public class AtomicIntegerRoundRobin { private final int totalIndexes; private final AtomicInteger atomicInteger = new AtomicInteger(-1); public AtomicIntegerRoundRobin(int totalIndexes) { this.totalIndexes = totalIndexes;...
2020-11-05 17:16:53
257
原创 ThreadLocal相关
测试ThreadLocal,每个线程独自有自己对应的变量,其实质是在Thread类中维护了一个ThreadLocal.ThreadLoaclMap的Entry。且这个Entry的key是弱引用。理解部分:Entry中的keyA指向一个ThreadLocal对象,而对应的ThreadLocal对象也有指向这个对象的引用(二者指向同一个对象),设置成弱引用就是为了对应的线程不存在的时候,不要因为有这个keyA,而使得ThreadLoaclMap中keyA对应的value还不能被垃圾回收static
2020-11-05 09:59:34
221
原创 idea 相关
idea 中 设置成eclipse的快捷键ctrl+o maven依赖树中找类alt+shift+l 自动生成对象引用代码alt+shift+z 自动包围代码(try-catch)Ctrl+shift+Num / 收起所有代码注释ctrl +Num * 打开所有代码注释
2020-11-04 16:02:31
135
原创 redis 过期数据
https://www.jianshu.com/p/60cc093d6c36过期数据删除策略 redis的过期数据删除策略使用了惰性删除和定期删除两种策略:惰性删除发生在redis处理读写请求的过程,如get/set等命令。 定期删除发生在redis内部定时任务执行过程中,限制占用cpu的时间。LRU配置参数Redis配置中和LRU有关的有三个:maxmemory: 配置Redis存储数据时指定限制的内存大小,比如100m。当缓存消耗的内存超过这个数值时, 将触发数据淘汰。该数据配置
2020-11-04 14:54:16
325
原创 ABA问题
ABA问题 时间顺序 线程1 线程2 说明 T1 X=A — 线程 1 加入监控 X T2 复杂运算开始 修改 X=B 线程 2 修改 X,此刻为 B T3 处理简单业务 — T4 修改 X=A 线程 2 修改 X,此刻又变回 A T5 结束线程 2 线程 2 结束 T6 检测X=A,验证通过,提交事务 — CAS 原理检测通过,因为和旧值保持一致 ...
2020-11-04 10:10:57
124
原创 java类加载
引用:https://www.jianshu.com/p/cc66138d72b1,https://blog.youkuaiyun.com/xinlingchengbao/article/details/88376479第一,Java 类加载的过程简介 一般来说,我们把 Java 的类加载过程分为三个主要步骤:加载,连接,初始化,具体行为在 Java 虚拟机规范里有非常详细的定义。 首先是加载过程(Loading),它是 Java 将字节码数据从不同的数据源读取到 JVM 中,并...
2020-11-03 16:55:27
114
原创 jvm内存模型
链接:https://www.jianshu.com/p/5d9618ec9146 程序计数器:它的生命周期与线程相同,线程私有。较小的内存区域,用以完成分支、循环、跳转、异常处理、线程恢复等基础功能。不会发生内存溢出(OutOfMemory=OOM)错误。 虚拟机栈:它的生命周期与线程相同,线程私有。虚拟机栈中存储了方法执行时相关信息,每个方法在调用时都会在虚拟机栈中创建一个方法帧,方法帧中包含了局部变量,参数,运行中间结果等信息。帧数超过限制(-Xss),就会出现StackOv.
2020-10-29 17:23:57
113
原创 垃圾回收gc
常用gc工具-----jvisualvm安装visual gc插件几张gc图g1gc 相关参数选项/默认值 说明 -XX:+UseG1GC 使用 G1 (Garbage First) 垃圾收集器 -XX:MaxGCPauseMillis=n 设置最大GC停顿时间(GC pause time)指标(target). 这是一个软性指标(soft goal), JVM 会尽量去达成这个目标. -XX:InitiatingHe...
2020-10-29 14:51:40
238
原创 redis----------redis-storage-------------pika
redis:内存级别redis-storage:内存+磁盘 支持ds_set指令,将数据直接放入磁盘pika:磁盘
2020-10-28 17:11:21
270
原创 bio,nio,select/poll,epoll
io的发展历程bio,nio,select/poll,epollJava的nio---》指的是new io 和多路复用器有关Linux 的nio 指的是none blocking io 指的是非阻塞()多路复用器有多个实现:select,poll,epoll(linux),kqueue(unix)linux系统产生了下面五种网络模式的方案。- 阻塞 I/O(blocking IO)- 非阻塞 I/O(nonblocking IO)- I/O 多路复用( IO multiplex...
2020-10-23 13:42:06
205
原创 线程池相关
ThreadPoolExcutor 继承关系 全参数构造函数:/** * Creates a new {@code ThreadPoolExecutor} with the given initial * parameters. * * @param corePoolSize the number of threads to keep in the pool, even * if they are idle, unless {@code allowCoreThreadT..
2020-10-21 16:18:28
109
原创 notify和notifyAll
package com.mine.testhttp;import javax.sound.midi.Soundbank;import java.sql.SQLOutput;import java.util.ArrayList;import java.util.List;import java.util.Map;import java.util.concurrent.locks.LockSupport;import java.util.stream.Collectors;/** * @.
2020-10-20 16:30:43
134
原创 spring bean 提前暴露以及循环依赖
相应源码位置:AbstractAutowireCapableBeanFactory.class// Eagerly cache singletons to be able to resolve circular references// even when triggered by lifecycle interfaces like BeanFactoryAware.boolean earlySingletonExposure = (mbd.isSingleton() && th.
2020-10-20 11:22:46
1360
原创 org.springblade.core.tool.jackson.JsonUtil源码,可参考编写个人jsonutil工具类
package org.springblade.core.tool.jackson;import com.fasterxml.jackson.core.JsonParser;import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.core.type.TypeReference;import com.fasterxml.jackson.databind.Deserializatio.
2020-10-19 13:26:58
3792
原创 hashmap源码分析
1.8中hashmap已经删除了transfer函数,原来导致形成环链的问题得以解决,不过依旧线程不安全,比如两个线程在同时put的时候,在第一个线程判断完hash冲突后,挂起,第二个线程也判断hash冲突,然后进行了插入,再切回第一个线程的时候会导致直接进行插入,因为此时hash冲突已经判断过【但此刻是形成了冲突,原来是没有冲突的】,会导致直接插入值,将第二个线程插入的值覆盖。1.8HashMap的putVal源码:final V putVal(int hash, K...
2020-10-16 15:44:51
1064
5
原创 happens-before 规则
链接:https://www.jianshu.com/p/9464bf340234为什么会有happens-before 规则?因为jvm会对代码进行编译优化,指令会出现重排序的情况,为了避免编译优化对并发编程安全性的影响,需要happens-before规则定义一些禁止编译优化的场景,保证并发编程的正确性。public class VolatileExample { int x = 0 ; volatile boolean v = false; public ..
2020-10-16 12:10:40
139
原创 Jackson ObjectMapper采用UTF-8编码?
Jackson自动检测源中使用的编码:根据JSON规范,只有有效编码为UTF-8,UTF-16和UTF-32。不能使用其他编码(如Latin-1)。 因此,自动检测很容易并且由解析器完成 - 因此没有接受编码检测。 因此,如果输入为UTF-8,则会被检测到。对于输出,UTF-8是默认值;但是,如果您明确要使用其他编码,则可以显式创建JsonGenerator(使用JsonEncoding的方法),并将其传递给ObjectMapper。或者在这两种情况下,您当然可以手动构建java.io.Reader
2020-10-14 11:50:16
4128
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人