springboot 获取当前项目在服务器的路径
1、获取当前项目在本地磁盘的根目录(获取当前项目路径的地址)
System.out.println(System.getProperty("user.dir")); //结果为: /D:/Idea/code/springboot
2、springboot获取当前服务器target/classes的路径--------------------------------------服务器中的地址
try { String str = ResourceUtils.getURL("classpath:").getPath(); System.out.println(str); } catch (FileNotFoundException e) { e.printStackTrace(); } //结果显示为: /D:/Idea/code/springboot/target/classes/