这个上传功能怎么获取服务器路径啊

img


我想获取项目所在服务器路径这样,之后部署项目也不用改了,可是我发现每次重启项目获得的路径都不一样这是哪里的问题啊应该怎么获取服务器路径啊

System.getProperty("user.dir") 或者 设置在配置文件里面试下

this.getClass().getClassLoader().getResource("").getPath();//获取工程classes 下的路径

File classPath = new ApplicationHome(getClass()).getSource();
String filePath = classPath.getParentFile().getPath()