dianxin-guizhou-forward
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
713B

  1. package com.ssjl.zhaobiao.guizhou.utils;
  2. import org.springframework.beans.BeansException;
  3. import org.springframework.context.ApplicationContext;
  4. import org.springframework.context.ApplicationContextAware;
  5. import org.springframework.stereotype.Component;
  6. @Component
  7. public class ApplicationContextProvider implements ApplicationContextAware {
  8. private static ApplicationContext context;
  9. private ApplicationContextProvider(){}
  10. @Override
  11. public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  12. context = applicationContext;
  13. }
  14. public static <T> T getBean(String name,Class<T> aClass){
  15. return context.getBean(name,aClass);
  16. }
  17. }