Spring获取bean

1.在spring-servlet.xml中配置

<!--业务类的配置-->
<bean id="locationTaskService" class="com.location.service.LocationTaskServiceImpl"></bean>

2.添加获取bean的代码

ApplicationContext ac=new ClassPathXmlApplicationContext("spring-servlet.xml");
LocationTaskService cd=(LocationTaskService) ac.getBean("locationTaskService");

posted on 2017-07-25 08:48  骑着乌龟漂流  阅读(122)  评论(0编辑  收藏  举报

导航