国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Spring(3.2.3)

2019-11-15 00:11:35
字體:
來源:轉載
供稿:網友
SPRing(3.2.3) - Beans(1): Spring 容器BeanFactory &applicationContext

org.springframework.beans.factory.BeanFactory 是最基本的 Spring 容器接口,它提供了管理 Bean 的一些基本功能。 BeanFactory 接口包含如下幾個基本方法:  Object getBean(String name) throws BeansException;  <T> T getBean(String name, Class<T> requiredType) throws BeansException;  boolean containsBean(String name);  Class<?> getType(String name) throws NoSuchBeanDefinitionException;

org.springframework.context.ApplicationContext 是org.springframework.beans.factory.BeanFactory 的子接口,除了提供BeanFactory 所支持的功能,ApplicationContext 還提供了一些額外的功能,如國際化支持、事件機制、資源訪問等。

Spring 配置文件的基本結構
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">        <bean id="..." class="..." >        <property name="..." value="..." />        <property name="..." ref="..." />    </bean>    </beans>

實例化容器

按文件系統路徑加載配置文件:

ApplicationContext appCtx = new FileSystemXmlApplicationContext("src/applicationContext.xml");

按類路徑加載配置多件:

ApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml");

加載多個配置文件:

ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"});

使用 Spring 容器
ExampleBean example = appCtx.getBean("example", ExampleBean.class);


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 凌海市| 辽源市| 格尔木市| 鄂托克旗| 云梦县| 蓬莱市| 天台县| 姜堰市| 隆昌县| 阳西县| 祁连县| 泗阳县| 六安市| 介休市| 花莲县| 石嘴山市| 荃湾区| 长子县| 大足县| 玉环县| 宽甸| 保德县| 托里县| 崇左市| 正定县| 平阳县| 平顶山市| 甘谷县| 平顺县| 萍乡市| 顺昌县| 东乡县| 阿拉善右旗| 新巴尔虎左旗| 定南县| 库车县| 阜城县| 通江县| 香河县| 深水埗区| 通辽市|