@Autowired认识

来源:互联网 发布:软件销售范围 编辑:程序博客网 时间:2024/06/05 00:30
package com.studySpring;   
import org.springframework.beans.factory.annotation.Autowired;   
  
public class Boss {   
  
    @Autowired  
    private Car car;   
  
    @Autowired  
    private Office office;   
  
    …   

}   

其中的@Autowired 会自动在spring的配置中找到名为car和名为office的bean,分别为这里两个私有成员变量进行注入。这里get/set方法可省略。


1 0
原创粉丝点击