作用:
1、扫描xxx(包名)包及其子包下的所有类。
2、并为添加了@Controller、@Service、@Component和@Repository修饰的类创建对象,并存入IoC容器。
context:component-scan作用
context:component-scan作用
3、如果@Controller、@Service、@Component和@Repository修饰的类中成原变量有@Autowired,则创建该类对象时会自动从IoC容器中获取该成员变量的值并赋给相应的变量
context:component-scan作用
context:component-scan作用
(注意:调用的是默认构造方法)

相关文章:

  • 2021-07-21
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
猜你喜欢
  • 2021-08-22
  • 2021-05-25
  • 2022-12-23
  • 2021-12-09
相关资源
相似解决方案