spring复习笔记.docx

上传人:枫** 文档编号:543537745 上传时间:2022-12-09 格式:DOCX 页数:16 大小:91.56KB
返回 下载 相关 举报
spring复习笔记.docx_第1页
第1页 / 共16页
spring复习笔记.docx_第2页
第2页 / 共16页
spring复习笔记.docx_第3页
第3页 / 共16页
spring复习笔记.docx_第4页
第4页 / 共16页
spring复习笔记.docx_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《spring复习笔记.docx》由会员分享,可在线阅读,更多相关《spring复习笔记.docx(16页珍藏版)》请在金锄头文库上搜索。

1、spring:业务层框架,管理bean的,核心组件是容器。spring方式打印helloworld业务类:GreetingService.javapackage com.spring.demo.spring1;/* * author xuyh * date 2013-6-18 下午11:16:06 * version v1.0 * description 问候服务类 */public class GreetingService private String greeting;public String getGreeting() return greeting;public void setG

2、reeting(String greeting) this.greeting = greeting;public void sayHello() System.out.println(hello: + greeting);maven配置文件: pom.xml4.0.0com.spring.demospring10.0.1-SNAPSHOTjarspring1http:/maven.apache.orgUTF-8junitjunit4.11org.springframeworkspring-core3.1.4.RELEASEorg.springframeworkspring-beans3.1.4

3、.RELEASEorg.springframeworkspring-aop3.1.4.RELEASEorg.springframeworkspring-context3.1.4.RELEASESpring 配置文件:ApplicationContext.xml测试类 : GreetingServiceTestpackage com.spring.demo.spring1;import org.junit.Test;import org.springframework.beans.factory.BeanFactory;import org.springframework.context.sup

4、port.ClassPathXmlApplicationContext;public class GreetingServiceTest /* 传统方式打印helloworld */Testpublic void testSayHello() GreetingService gs = new GreetingService();gs.setGreeting(xuyh);gs.sayHello();/* spring方式打印helloworld */Testpublic void testSayHelloSpring() BeanFactory bf = new ClassPathXmlAppl

5、icationContext(ApplicationContext.xml);GreetingService gs = (GreetingService) bf.getBean(greetingService);gs.sayHello();更多的属性或对象package com.spring.demo.spring1;/* * author xuyh * date 2013-6-18 下午11:16:06 * version v1.0 * description 问候服务类 */public class GreetingService private String greeting;priva

6、te String greeting2;private ByeService byeService;public String getGreeting() return greeting;public void setGreeting(String greeting) this.greeting = greeting;public void sayHello() System.out.println(hello: + greeting);public String getGreeting2() return greeting2;public void setGreeting2(String g

7、reeting2) this.greeting2 = greeting2;public void sayHello2() System.out.println(hello: + greeting2);public ByeService getByeService() return byeService;public void setByeService(ByeService byeService) this.byeService = byeService;public void sayGreetingBye()byeService.sayBye();package com.spring.demo.spring1;/* * author xuyh * date 2013-6-18 下午11:16:06 * version v1.0 * description 欢送服务类 */public class ByeService private String bye;public String getBye() return bye;public void setBye(String greeting) this.bye = greeting;public void sayBye() System.out.println(bye: + bye);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号