Created
January 16, 2020 08:36
-
-
Save ereshzealous/b69c5410239a133d5661aaae74ba7300 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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