刚才在学习Java 使用properties类,遇到这样的错误: Cannot make a static reference to the non-static method getClass() from the type Object 以前使用过getClass,不晓得怎么用的,后来在stackoverflow看到同样的问题 I have a class that must have some static methods. Inside these static methods I ne…
14down votefavorite An article on classloading states that the method getClass() should not be called within a constructor because: object initialization will be complete only at the exit of the constructor code. The example they gave was: public c…
读取resources下文件的方法 网上有问答如下:问: new FileInputStream("src/main/resources/all.properties") new FileInputStream("./src/main/resources/all.properties") 上面两个无法读取maven下资源文件目录下的文件嘛,总是提示找不到该路径,这么写错了嘛,但是我的其他maven可以读取 答: 要取编译后的路径,而不是你看到的src/main/re…