All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.benma666.sjsj.myutils.Config Maven / Gradle / Ivy

package cn.benma666.sjsj.myutils;

import cn.benma666.iframe.Conf;
import cn.benma666.iframe.ConfAbstract;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

@Component
public class Config extends ConfAbstract implements EnvironmentPostProcessor {

    public Config() {
        super();
    }

    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        this.config=environment;
        Conf.setConfig(this);
//        MutablePropertySources propertySources = environment.getPropertySources();
//        propertySources.addLast(new MyPropertySource("sjsj", new Conf()));
    }

    /**
     * 获取配置
     * @param key 键
     * @return 值
     */
    public String getVal(String key) {
        return config.getProperty(key);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy