Spring Boot手动装配有哪几种方式?
作者:互联网
2.Spring Boot手动装配有哪几种方式?
1.使用模式注解 @Component/@Controller/@Component/@Service/@Repository 等
2.使用配置类 @Configuration 与 @Bean
3.使用模块装配 @EnableXXX 与 @Import
使用 @Configuration 与 @Bean一旦注册过多,会导致编码成本高,维护不灵活等问题。
SpringFramework 提供了模块装配功能,通过给配置类标注 @EnableXXX 注解,再在注解上标注 @Import 注解,即可完成组件装配的效果。
标签:装配,Spring,Component,Boot,Bean,哪几种,注解,Import 来源: https://blog.csdn.net/weixin_45014721/article/details/120427685