一、@Component 用注解来装配bean

1、

注解@Component方式代替xml装配bean

 

 注解@Component方式代替xml装配bean

 

 

2、对类使用注解,装配bean:

 注解@Component方式代替xml装配bean

 

 

3、类中,注入其他对象:

 注解@Component方式代替xml装配bean

 

 二、bean.xml中配置@Componet方式装配bean

1、开启注解装配bean依赖注入方式和类使用的自动注入

注解@Component方式代替xml装配bean

 

 2、

注解@Component方式代替xml装配bean

 

 其中,通过类型获取对象时候,传入接口类和接口的实现类都可以;

 

相关文章:

  • 2021-09-03
  • 2021-10-13
  • 2021-03-30
  • 2021-11-18
  • 2021-09-19
  • 2021-04-06
  • 2022-12-23
猜你喜欢
  • 2021-06-07
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
相关资源
相似解决方案