package io.stockgeeks.metrics;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
@Service
public class SpringBeanUtil implements ApplicationContextAware {
private static ApplicationContext context;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static <T> T getBean(Class<T> beanClass) {
return context.getBean(beanClass);
}
}
Last active
April 15, 2019 21:22
-
-
Save mmaia/9fa5cfee05cf04170a2eaa133d15fda4 to your computer and use it in GitHub Desktop.
Spring boot tricks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment