获取jar包发布到服务器后的版本路径 神灭龙魔导士 2022-02-23 355 阅读1分钟 String path = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); 获取jar包发布到服务器后的版本路径 String path = this.class.getProtectionDomain().getCodeSource().getLocation() 如果执行当前类.class会获取当前类绝对路径,, 如果打包成jar了,会获取当前jar的绝对路路径