JAVA类中获取项目路径

在java web项目中获取项目的src/main/resource下的文件路径

当前类名.class.getClassLoader().getResource("/").getPath();

  比如我的当前类名叫Demo

那么:

Demo.class.getClassLoader().getResource("/").getPath();

  

原文地址:https://www.cnblogs.com/guokai870510826/p/7358606.html