方式一:
InputStream in = Test.class .getResourceAsStream("/env.properties"); URL url = Test.class.getResource("env.properties") ;
說明:env.properties文件在src的根目錄下,文件名前有斜杠
方式二:
InputStream in = Test.class.getClassLoader() .getResourceAsStream("env.properties"); URL url = Test.class.getClassLoader().getResource("env.properties") ;
方式三:
InputStream in = Thread.currentThread().getContextClassLoader()
.getResourceAsStream("ExcelModeMappingl.xml");
原貼地址:https://yq.aliyun.com/articles/40852