风言枫语  
java类:
public class MySpringContext implements ApplicationContextAware{
  private static ApplicationContext context;//声明一个静态变量保存 
  @SuppressWarnings("static-access")
  public void setApplicationContext(ApplicationContext contex) throws BeansException {
    this.context=contex; 
  }
  public static ApplicationContext getContext(){ 
    return context; 
  }

}
 
spring配置文件中配置:
<bean class="com.tsingsoft.basedata.sendMessage.MySpringContext"></bean>

 

调用类调用:

ApplicationContext app =MySpringContext.getContext();


posted on 2013-09-04 19:22  风言枫语  阅读(200)  评论(0编辑  收藏  举报