上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页
摘要: 如果Bean A 在创建前需要先创建BeanB此时就可以使用DependsOn注解 @Configuration public class MyConfig { @Bean @DependsOn("apple") public Student student(){ System.out.printl 阅读全文
posted @ 2020-08-03 19:03 yangxiaohui227 阅读(3230) 评论(0) 推荐(0)
摘要: 背景,如果有一个类C,需要用到类B,如果使用@Autowired注解注入B,那么B每次调用都是同一个对象,即使B不是单例的,现在我希望每次调用B都是不一样的,那么实现方案有2个: 方案A : 每次从容器中获取B: @Component @Scope(scopeName= ConfigurableBe 阅读全文
posted @ 2020-08-03 18:55 yangxiaohui227 阅读(2389) 评论(0) 推荐(1)
摘要: 1.下面结果执行后会报空指针吗? public class A { public static int num=2; } public class App { public static void main( String[] args ) { A a=null; System.out.printl 阅读全文
posted @ 2020-08-03 10:22 yangxiaohui227 阅读(116) 评论(0) 推荐(0)
摘要: 背景: 在spring ioc refresh()方法中,看到了如下逻辑: 要理解该逻辑的原理,先看场景:有个接口InterFaceA,它有2个实现类A1和A2 那么,如果一个类C 依赖了InterFaceA,此时sprig不知道要注入哪个实现类: public interface InterFac 阅读全文
posted @ 2020-08-01 11:41 yangxiaohui227 阅读(1185) 评论(0) 推荐(0)
摘要: 测试环境代码: @Configuration @ComponentScan("com.yang.xiao.hui.ioc") @Conditional(MyCondition.class) public class App { public static void main( String[] ar 阅读全文
posted @ 2020-07-31 17:22 yangxiaohui227 阅读(222) 评论(0) 推荐(0)
摘要: 一.测试环境的搭建: public class Apple { } @Component public class MyComponet { } public class MyCondition implements Condition { @Override public boolean matc 阅读全文
posted @ 2020-07-30 16:32 yangxiaohui227 阅读(584) 评论(0) 推荐(0)
摘要: 一.源码环境的搭建: @Component @Scope(scopeName = ConfigurableBeanFactory.SCOPE_SINGLETON,proxyMode = ScopedProxyMode.TARGET_CLASS) public class MyMath impleme 阅读全文
posted @ 2020-07-30 12:33 yangxiaohui227 阅读(960) 评论(0) 推荐(0)
摘要: 在上一篇aop源码分析时,我们已经分析了一个bean被代理的详细过程,参考:https://www.cnblogs.com/yangxiaohui227/p/13266014.html 本次主要是分析目标方法的执行过程: 测试代码在git : https://gitee.com/yangxioahu 阅读全文
posted @ 2020-07-09 12:50 yangxiaohui227 阅读(302) 评论(0) 推荐(0)
摘要: 测试项目已上传到码云,可以下载:https://gitee.com/yangxioahui/aopdemo.git 具体如下: public interface Calc { Integer add(int num1,int num2); }//目标是对add 方法进行切入 @Component p 阅读全文
posted @ 2020-07-08 11:36 yangxiaohui227 阅读(383) 评论(0) 推荐(0)
摘要: 测试环境搭建: 本次搭建是基于springboot来实现的,代码在码云的链接:https://gitee.com/yangxioahui/thymeleaf.git DispatcherServlet核心流程在上一篇源码分析已经做了详细讲解 了,参考: https://www.cnblogs.com 阅读全文
posted @ 2020-07-04 15:27 yangxiaohui227 阅读(938) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页