摘要: <?xml version="1.0" encoding="UTF-8"?><!--more--><beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://www.springframework.org/sc 阅读全文
posted @ 2021-01-14 19:38 _Shing 阅读(108) 评论(0) 推荐(0)
摘要: @Configuration:表明这是个配置类,该类应该包含在spring应用上下文中。如果@Bean修饰的方法被 @Configuration修饰,那么方法是单例的。 @Bean:注解会告诉spring这个返回返回一个对象。该对象要注册为spring应用上下文中的bean,方法体中 包含了最终产生 阅读全文
posted @ 2021-01-14 19:35 _Shing 阅读(160) 评论(0) 推荐(0)
摘要: Spring从两个角度来实现自动化装配: 组建扫描(component scanning):@ComponentScan默认会扫描与配置类相同的包与该包的子包。查找 带有@Component注解的类并为其创建bean。 @Component:被扫描到会创建bean。 自动装配(autowried): 阅读全文
posted @ 2021-01-14 19:33 _Shing 阅读(109) 评论(0) 推荐(0)
摘要: 忽略,限制和排序查询选项1 db.reviews.find({'product_id':product['_id']}).skip(0).limit(12).sort({'helpful_votes':-1}) 1 1 db.reviews.find({'product_id':product['_ 阅读全文
posted @ 2021-01-14 19:30 _Shing 阅读(168) 评论(0) 推荐(0)
摘要: 当经历过resolveBeforeInstantiation方法后,程序有两个选择。如果创建了代理或者说重写了InstantiationAwareBeanPostProcessor的postProcessBeforeInstantiation方法并在方法postProcessBeforeinstan 阅读全文
posted @ 2021-01-13 17:17 _Shing 阅读(223) 评论(0) 推荐(0)
摘要: 5.6.1什么是循环依赖、循环调用 循环依赖:实例化bean是一个复杂的过程。循环依赖就是两个或者多个bean相互之间持有对方,比如TestA引用TestB,TestB引用TestA,则它们最终反映为一个环。 循环调用:循环调用是方法之间的环调用。循环调用是无法解决的,除非有终结条件,否则就是死循环 阅读全文
posted @ 2021-01-13 17:16 _Shing 阅读(203) 评论(0) 推荐(0)
摘要: AbstractAutowireCapableBeanFactory protected Object createBean(String beanName, RootBeanDefinition mbd, @Nullable Object[] args) throws BeanCreationEx 阅读全文
posted @ 2021-01-13 17:15 _Shing 阅读(156) 评论(0) 推荐(0)
摘要: DefaultSingletonBeanRegistry public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) { Assert.notNull(beanName, "Bean name must 阅读全文
posted @ 2021-01-13 17:14 _Shing 阅读(172) 评论(0) 推荐(0)
摘要: 让我们尝试打开"5.bean的加载 - 3) bean的实例化的大门": AbstractBeanFactory protected Object getObjectForBeanInstance( Object beanInstance, String name, String beanName, 阅读全文
posted @ 2021-01-13 17:13 _Shing 阅读(305) 评论(0) 推荐(0)
摘要: DefaultSingletonBeanRegistry public Object getSingleton(String beanName) { //参数true设置标识允许早期依赖(提前引用) return getSingleton(beanName, true); } protected O 阅读全文
posted @ 2021-01-13 17:12 _Shing 阅读(189) 评论(0) 推荐(0)