small-spring
small-spring copied to clipboard
🌱《 Spring 手撸专栏》,本专栏以 Spring 源码学习为目的,通过手写简化版 Spring 框架,了解 Spring 核心原理。在手写的过程中会简化 Spring 源码,摘取整体框架中的核心逻辑,简化代码实现过程,保留核心功能,例...
执行jdk代理invoke方法时,此处总是返回false; if (advised.getMethodMatcher().matches(method, advised.getTargetSource().getTarget().getClass())) { MethodInterceptor methodInterceptor = advised.getMethodInterceptor(); return methodInterceptor.invoke(new ReflectiveMethodInvocation(advised.getTargetSource().getTarget(), method, args)); } 原因是使调用matches()f方法时;jdk传入的方法是接口的抽法, ()pointcutExpression.matchesMethodExecution(method).alwaysMatches(); 这儿改用方法名和形参个数进行方法的匹配,jdk方法拦截正常 if (matches(targetClass)) { Method[] declaredMethods = targetClass.getDeclaredMethods(); for (Method declaredMethod : declaredMethods)...
1. ConfigurableListableBeanFactory#addBeanPostProcessor 接口方法可以删掉,不需要
修改small-spring-step-17下的pom org.apache.maven.plugins maven-compiler-plugin 3.1 1.8 1.8 UTF-8 -Xlint:deprecation ${java.home}\lib\rt.jar;${java.home}\lib\jce.jar


第6条-核心类实现(DefaultSingletonBeanRegistry)----------DefaultListableBeanFactory 实现BeanDefinitionRegistry接口,但文章的前面的出现这个接口的创建
1. 删除ConfigurableListableBeanFactory接口中的重复定义的方法addBeanPostProcessor 2. pom中引入validation-api依赖,将@Nullable注解的引用类从com.sun.istack.internal切换为org.jetbrains.annotations 3. 优化.gitignore 忽略所有的.iml和class文件

 