当前位置: 代码迷 >> 综合 >> 获取jar包发布到服务器后的版本路径
  详细解决方案

获取jar包发布到服务器后的版本路径

热度:44   发布时间:2024-02-07 16:15:54.0

String path = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();

获取jar包发布到服务器后的版本路径

 

String path = this.class.getProtectionDomain().getCodeSource().getLocation()

如果执行当前类.class会获取当前类绝对路径,,

如果打包成jar了,会获取当前jar的绝对路路径

  相关解决方案