JAVA类中获取项目路径时间:2023-03-09 22:11:36 在java web项目中获取项目的src/main/resource下的文件路径 当前类名.class.getClassLoader().getResource("/").getPath(); 比如我的当前类名叫Demo 那么: Demo.class.getClassLoader().getResource("/").getPath();