SpringBoot自动装配

昨天学习了Spring框架的手动装配,今天来看下SpringBoot的自动化装配。

定义:基于约定大于配置的原则,实现Spring组件自动装配的目的

底层装配技术:

  • Spring模式注解装配
  • Spring@Enable模块装配
  • Spring条件装配
  • Spring工厂加载机制
    • 实现类:SpringFactoriesLoader
    • 配置资源:META-INF/spring.factories

Spring Framework手动装配

Spring Boot 的自动装配源于Spring Framework的手动装配。

1. Spring模式注解装配

定义:一种用于声明在应用中扮演”组件”角色的注解

举例

Spring框架中常见的@Component@Service@Configuration等等。

装配方式:

  1. 配置文件xml中配置<context:component-scan>

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×