读取Properties出错,求高手指正!
初学Java .目的是读取配置文件,但是总是报错“静态变量非最终值”之类的错误?
public class dbUnit { private static Properties dbConfig; static { try { InputStream dbPropertiesIO = dbUnit.class.getResourceAsStream("/dbConfig.properties"); dbConfig.load(dbPropertiesIO); dbPropertiesIO.close(); } catch (Exception e) { throw new ExceptionInInitializerError(e); } } public static String getPop() { return dbConfig.getProperty("server"); }}