Spring中@Component和@Configuration的區別
正文
@Configuration public class BeanConfig {}複製程式碼
問題
@Configuration public class BeanConfig { //@Scope("prototype") @Bean public Role role(){ return new Role(); } @Bean public User user(){ Role r1=role(); Role r2=role(); System.out.println(r1==r2); return new User(); }}複製程式碼
原始碼
org.springframework.context.annotation.AnnotationConfigApplicationContext#AnnotationConfigApplicationContext()
org.springframework.context.support.AbstractApplicationContext#refresh() 方法中的invokeBeanFactoryPostProcessors(beanFactory)org.springframework.context.annotation.ConfigurationClassPostProcessor#postProcessBeanFactory
org.springframework.context.annotation.ConfigurationClassPostProcessor#enhanceConfigurationClasses
總結
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70021881/viewspace-2917421/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- @Configuration與@Component作為配置類的區別
- @Component和@Configuration作為配置類的差別
- @Component和@Bean的區別Bean
- @Bean和@Component之間的區別?Bean
- React.createClass和extends Component的區別React
- Spring中Filter和Interceptor的區別SpringFilter
- @Component, @Repository, @Service的區別
- spring和springmvc的區別SpringMVC
- 【Java面試】Spring中 BeanFactory和FactoryBean的區別Java面試SpringBean
- Spring MVC和Spring Boot的區別 - hackernoonMVCSpring Boot
- Spring - 配置檔案中的classpath: 和 classpath*: 的區別Spring
- 【Spring 註解】@Configuration和@BeanSpringBean
- spring中的FactoryBean與ObjectFactory的區別SpringBeanObject
- Spring框架和Spring boot有啥區別?框架Spring Boot
- Spring Cloud:Zookeeper和Eureka的區別在哪?SpringCloud
- Strust2和Spring MVC的區別RustSpringMVC
- JavaScript中for in 和for of的區別JavaScript
- Js中for in 和for of的區別JS
- mysql中!=和is not的區別MySql
- Python中is和==的區別Python
- JavaScript中==和===的區別JavaScript
- Linux中“>”和“>>”的區別Linux
- Python 中 is 和 == 的區別Python
- mysql中“ ‘ “和 “ ` “的區別MySql
- Spring生態系統中的Reactor、WebFlux和RSocket區別? - FranciscoSpringReactWebUX
- 9.(轉)Spring Configuration Check Unmapped Spring configuration files foundSpringAPP
- PHP 中的 -> 和 :: 的區別PHP
- Spring處理@Configuration的分析Spring
- MyBatis-06-Spring的SqlSession和原始區別MyBatisSpringSQLSession
- Spring set注入和構造注入的區別Spring
- spring 解析 @Configuration 流程Spring
- java 中equals和==的區別Java
- SQL中where和on的區別SQL
- deferred中done和then的區別
- Spring和SpringBoot比較,解惑區別Spring Boot
- SpringBoot和Spring有什麼區別?Spring Boot
- Spring中ref local=""與ref bean=""的區別SpringBean
- JS中的!=、== 、!==、=== 的用法和區別JS