1、安装Spring插件
(1)插件包:springsource-tool-suite-3.4.0.RELEASE-e4.3.1-updatesite.zip
(2 ) 操作步骤:参照《[尚硅谷]_参考资料:安装Springtools插件.doc》
2、搭建Spring运行环境
- 加入JAR包① Spring自身JAR包:spring-framework-4.0.0.RELEASE\libs目录下spring-beans-4.0.0.RELEASE.jarspring-context-4.0.0.RELEASE.jarspring-core-4.0.0.RELEASE.jarspring-expression-4.0.0.RELEASE.jar② commons-logging-1.1.1.jar2) 在Spring Tool Suite工具中通过如下步骤创建Spring的配置文件 (STS可以自动创建)(STS就是eclips+Springtools) ① File->New->Spring Bean Configuration File ② 为文件取名字 例如:A
下边做一个小测试 - 目标:使用Spring创建对象,为属性赋值
- 创建Student类
3)创建Spring的配置文件
4) 通过Spring的IOC容器创建Student类实例
//1.创建IOC容器对象ApplicationContext iocContainer = new ClassPathXmlApplicationContext(“helloworld.xml”);
//2.根据id值获取bean实例对象Student student = (Student) iocContainer.getBean(“student”);//3.打印beanSystem.out.println(student);