学无先后,达者为师

网站首页 编程语言 正文

Springboot获取jar包同级目录

作者:提里奥丶弗丁 更新时间: 2023-07-18 编程语言
	public String getPath() {
		String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
		if (System.getProperty("os.name").contains("dows")) {
			return path.substring(1).replace("target/classes/", "");
		}
		if (path.contains("jar")) {
			path = path.substring(0, path.lastIndexOf("."));
			path = path.substring(0, path.lastIndexOf("/")+1);
		}
		return path.substring(path.indexOf(":")+1);
	}

原文链接:https://blog.csdn.net/m0_65014849/article/details/131638173

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新