SpringBoot的注解功能

30 阅读1分钟

@Configuration 和 @Component 有什么区别?

1、日常使用上来说,@Component和@service用法类似,而@Configuration则和Xml元数据文件一样,用来承载bean配置。 2、实现原理上来说,@Configuration默认的模式下会启动cglib代理,类里的bean是单例的。而Component每次创建都会实现一个新的类。

@Configuration和XML有什么区别 @Configuration 使用上有哪些约束?

@Value、@PropertySource 和 @Configuration? Spring如何处理带@Configuration @Import的类? @Profile有什么用? @Configuration 如何嵌套?