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

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

手動獲取Spring上下文和Bean對象

2019-11-10 20:15:40
字體:
供稿:網(wǎng)友

示例

/** * 手動獲取SPRing上下文和Bean對象 * * @Author YinWenBing * @Date 2017/1/6 17:07 */public class applicationUtil implements ApplicationContextAware { private static ApplicationContext applicationContext; /** * 加載Spring配置文件時,如果Spring配置文件中所定義的Bean類實現(xiàn)了ApplicationContextAware接口,會自動調(diào)用該方法 * * @param applicationContext * @throws BeansException */ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { ApplicationUtil.applicationContext = applicationContext; } /** * 獲取Spring上下文 * @return */ public static ApplicationContext getApplicationContext() { return applicationContext; } /** * 獲取Spring Bean * @param name * @return * @throws BeansException */ public static Object getBean(String name) throws BeansException { return applicationContext.getBean(name); }}

在Spring配置文件中手動配置ApplicationUtil Bean

<bean id="applicationUtil" class="com.nb.soa.common.util.ApplicationUtil"></bean>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 公主岭市| 崇义县| 榆林市| 林州市| 阿合奇县| 双桥区| 海丰县| 汕头市| 茶陵县| 桓台县| 苗栗市| 潍坊市| 尚义县| 上犹县| 阜阳市| 吐鲁番市| 邵武市| 古浪县| 吉木乃县| 贵南县| 威信县| 东港市| 宜川县| 淄博市| 综艺| 古田县| 南郑县| 庐江县| 颍上县| 启东市| 东阿县| 崇明县| 公安县| 汉沽区| 夏邑县| 万载县| 霸州市| 耒阳市| 北川| 军事| 岳西县|