Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Created January 16, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ereshzealous/b69c5410239a133d5661aaae74ba7300 to your computer and use it in GitHub Desktop.
Save ereshzealous/b69c5410239a133d5661aaae74ba7300 to your computer and use it in GitHub Desktop.
package com.minikube.sample.rest.controller;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
/**
* Created by Eresh Gorantla on 09/May/2019
**/
@Service
public class BeanUtil implements ApplicationContextAware {
private static ApplicationContext context;
public BeanUtil() {
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static <T> T getBean(Class<T> beanClass) {
return context.getBean(beanClass);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment