Spring(四) 自动扫描管理
来源:互联网 发布:maxwell仿真软件 编辑:程序博客网 时间:2024/06/15 14:18
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="cn.itcast"/>
public class PersonServiceBean implements PersonService {
private PersonDao personDao;
public void setPersonDao(PersonDao personDao) {
this.personDao = personDao;
PersonService personService = (PersonService)ctx.getBean("personServiceBean");/personService
System.out.println(personService);
ctx.close();
--------------------------------------------------------------------------------------------------------------------------------------
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="cn.itcast"/>
</beans>
@Service /@Service("personService") // Scope("prototype")public class PersonServiceBean implements PersonService {
private PersonDao personDao;
public void setPersonDao(PersonDao personDao) {
this.personDao = personDao;
}
@PostConstruct 参见: --------Spring(二)bean实例化-----
public void init(){
System.out.println("初始化");
}
@PreDestroy
public void destory(){
System.out.println("开闭资源");
}
}
AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");PersonService personService = (PersonService)ctx.getBean("personServiceBean");/personService
System.out.println(personService);
ctx.close();
--------------------------------------------------------------------------------------------------------------------------------------
- Spring(四) 自动扫描管理
- spring自动扫描和管理
- Spring-自动扫描管理bean
- Spring、Spring自动扫描和管理Bean
- 让Spring自动扫描和管理Bean
- Spring自动扫描和管理Bean
- spring自动扫描和管理bean
- Spring自动扫描和管理Bean
- 让Spring自动扫描和管理Bean
- Spring自动扫描和管理bean
- Spring自动扫描和管理Bean
- Spring学习笔记(9)----让Spring自动扫描和管理Bean
- Spring学习笔记(9)----让Spring自动扫描和管理Bean
- Spring(九)让Spring自动扫描和管理Bean
- JavaEE_SSH_Spring学习笔记(9)----让Spring自动扫描和管理Bean
- 第二章 IoC Spring自动扫描和管理Bean
- spring_让 spring自动扫描和管理bean
- spring自动扫描机制
- javascript 获取节点
- Axure RP 6.5 基础入门学习目录
- HDU 1150 二分图匹配 最小点覆盖
- HttpWebRequest缺少Using集的引用
- 每个注册用户都有自已的二级域名
- Spring(四) 自动扫描管理
- oracle 中常用关键字解析
- 触摸屏驱动分析
- spring常用的工具类
- Yii框架之数据访问对象 (DAO)
- mysql 性能优化系列
- VB Socket编程
- .equals(username) 和 username.equals("")的区别
- centos FTP服务器的架设和配置