spring的依赖注入
1.spring依赖注入的方式: (依赖注入:UserService依赖于OrderService 需要@Autowired注入 orderservice的实例)
手动注入:
①spring.xml中property方式 (本质:setter方法):

②spring.xml中constructor方式(本质:构造器方法):

自动注入 :
①XML的自动注入(底层还是setter方法和constructor方法):

②@Autowired注解注入:

2.@Autowired注解可以在哪里使用? 先通过类型在容器中找(byType) 找不到就通过名称查找(byName)
①属性
②方法:


浙公网安备 33010602011771号