idea取不到resources下的文件,情况处理~

配置:


     
    
        
            src/resources
            
                */*.properties
            
            false
        
    

读取文件:

private static Properties props;

/**
 * 静态代码块只执行一次
 */
static {
    String fileName = "xxxxxxxxx.properties";
    props = new Properties();
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream inputStream = classLoader.getResourceAsStream(fileName);
        props.load(inputStream);
    } catch (IOException e) {
        logger.error("配置文件读取异常", e);
    }
}

你可能感兴趣的:(日常问题)