相关文章推荐
暴躁的石榴  ·  翻译 - Dolibarr ERP CRM ...·  3 月前    · 
不羁的饺子  ·  Debezium | Apache Flink·  3 月前    · 
潇洒的茶壶  ·  LinearGradient class ...·  11 月前    · 
爱看球的哑铃  ·  Mathpix ...·  1 年前    · 
淡定的葡萄  ·  git push ...·  2 年前    · 
英勇无比的玉米  ·  Weird behaviour of ...·  2 年前    · 
·  阅读

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

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

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

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

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

分类:
后端
标签: