可以导成jar包来用
class="java">
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class SpringUtils
implements ApplicationContextAware
{
private static ApplicationContext applicationContext;
public static ApplicationContext getApplicationContext()
{
return applicationContext;
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
applicationContext = applicationContext;
}
public static Object getBean(String paramString) {
return applicationContext.getBean(paramString);
}
}