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和@Bean的區別Bean
- @Bean和@Component之間的區別?Bean
- React.createClass和extends Component的區別React
- Spring中Filter和Interceptor的區別SpringFilter
- spring配置中classpath和classpath*的區別Spring
- 【Java面試】Spring中 BeanFactory和FactoryBean的區別Java面試SpringBean
- @Component, @Repository, @Service的區別
- Spring - 配置檔案中的classpath: 和 classpath*: 的區別Spring
- spring和springmvc的區別SpringMVC
- Spring MVC和Spring Boot的區別 - hackernoonMVCSpring Boot
- mysql中!=和is not的區別MySql
- JavaScript中for in 和for of的區別JavaScript
- mysql中“ ‘ “和 “ ` “的區別MySql
- Js中for in 和for of的區別JS
- JavaScript中==和===的區別JavaScript
- spring中的FactoryBean與ObjectFactory的區別SpringBeanObject
- PHP 中的 -> 和 :: 的區別PHP
- Mybatis中#{}和${}傳參的區別及#和$的區別小結MyBatis
- Spring生態系統中的Reactor、WebFlux和RSocket區別? - FranciscoSpringReactWebUX
- java 中equals和==的區別Java
- SQL中where和on的區別SQL
- Python 中 is 和 == 的區別Python
- Python中is和==的區別Python
- Java中equals和==的區別Java
- oracle中in和exists的區別Oracle
- Linux中“>”和“>>”的區別Linux
- Spring Cloud:Zookeeper和Eureka的區別在哪?SpringCloud
- spring @component的作用Spring
- JS中的!=、== 、!==、=== 的用法和區別JS
- java中的==和equal的區別Java
- JS中的!=、== 、!==、===的用法和區別。JS
- Spring框架和Spring boot有啥區別?框架Spring Boot
- Spring中ref local=""與ref bean=""的區別SpringBean
- js中!和!!的區別與用法JS
- javascrit中undefined和null的區別JavaUndefinedNull
- swift中Class和Struct的區別SwiftStruct
- js中AMD和CMD的區別JS