java获取resource路径:
方法1:
Thread.currentThread().getContextClassLoader().getResource("de.py").getPath().replaceFirst("/","")
输出:E:/p/E/s/n/target/classes/de.py
方法2:这个方法需要try catch
(ResourceUtils.getURL("classpath:").getPath()+"de.py").replaceFirst("/","")
输出:E:/p/E/s/n/target/classes/de.py
方法3:这个方法需要try catch
ClassLoader.getSystemClassLoader().getResource("de.py").getPath().replaceFirst("/","")
输出:E:/p/E/s/n/target/classes/de.py
方法4:
ClassLoader.getSystemResource("de.py").getPath().replaceFirst("/","")
输出:E:/p/E/s/n/target/classes/de.py
方法5:不推荐
src/main/resources/properties/test.properties