package com.gci.boot.common.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * spring上下文工具
 *
 * @author chenzw
 * @date 2023/8/14
 */
public final class SpringEnvironmentUtil {

	private static Environment environment;

	/**
	 * 初始化，注入ApplicationContext对象
	 */
	public static class Initializer implements EnvironmentAware {

		@Override
		public void setEnvironment(Environment environment) {
			SpringEnvironmentUtil.environment = environment;
		}
	}

	public String getProperty(String propName){
		return environment.getProperty(propName);
	}
}
