1.1.1 @Component 创建对象 value 对象名称(spring 唯一)
@Component(value = "myStudent")
等同于
1.1.2 省略value
@Component("myStudent")
1.1.3 直接省略
@Component
容器获得时直接类名小写
Student s= (Student) ac.getBean("student");
1.2 声明扫描组件 base-package 为Component创建的对象文件目录
1.3 创建容器并获得对象
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
Student s= (Student) ac.getBean("myStudent");
System.out.println(s);
spring 中同类型的还有
@Repository
@Service
@Controller
用法同Component一致,作用:给项目分层



