ConfigUtil 系统配置文件参获取类

package net.joystart.common.util;

 

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

 
/**
 * 
 * @author yang yanqing
 * @date 2016年7月7日
 * ConfigUtil 系统配置文件参获取类
 */
@Component
public  class ConfigUtil
{
	private ConfigUtil(){
		
	}
    public static Properties pro = new Properties();
    static{
    	Resource resource = new ClassPathResource("/config.properties", ConfigUtil.class);
    	
    	try (InputStream inputStream = resource.getInputStream()){
			if(null !=inputStream){
				pro.load(inputStream); 
			}
		} catch (IOException e) {
			e.printStackTrace();
		} 
    }
    
}

  

原文地址:https://www.cnblogs.com/cuijinlong/p/7595664.html