1.新技能:classLoader, static方法,动态加载文件资源

public class FileReader{

private static final String

private static final String CONFIG_FILE = "a.properties";

  private static final String url="com/......";写你项目路径下的properties文件

    protected static Properties p = new Properties();

static{

init(url);

}

private void init(String resour) throws Exception{

InputStream in=new InputStream(this.class.getClassLoader.getResourceAsStream(resour));

p.load(in);

 

}

public static String getValue(String key){

return p.get(key);

}

}

 

2.这样。你就可以通过FileReader.getValue("key"),读取src/main/java,和java/mian/resource下的a.properties文件了