美文网首页
使用system.property获取项目绝对路径

使用system.property获取项目绝对路径

作者: 洋__ | 来源:发表于2016-12-13 09:46 被阅读65次

由于在rpc服务中使用了System.getProperty("user.dir")方式去获取当前srv项目的绝对路径

使用过程如下:

String userDir = System.getProperty("user.dir");
String home = userDir.substring(0, userDir.lastIndexOf('/'));
System.setProperty("home", home);

项目文件目录结构如下

Paste_Image.png
String locationPath = StringUtils.join(       
 new String[]{                
System.getProperty("home"),                
"config",                
"init",                
"location.txt"        },     
   File.separator);

相关文章

网友评论

      本文标题:使用system.property获取项目绝对路径

      本文链接:https://www.haomeiwen.com/subject/zqbvmttx.html