采用如下方法:
public void test(){ String class_str = this.getClass().getResource("/logback.xml").getPath(); String class_str2 = TempTest.class.getResource("/logback.xml").getPath(); String classLoader_str = this.getClass().getClassLoader().getResource("logback.xml").getPath(); InputStream is = this.getClass().getClassLoader().getResourceAsStream("logback.xml"); System.out.println(class_str); System.out.println(class_str2); System.out.println(classLoader_str); System.out.println(is == null ); }