Springboot获取jar包同级目录

	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);
	}

你可能感兴趣的:(spring,boot,jar,后端)