|
|
@@ -33,7 +33,15 @@ public final class PathUtil {
|
|
|
try {
|
|
|
filePath = URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8.name());
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
- throw new ClassWinterException(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * C:\Users\JustryDeng\Desktop\file:\E:\Java\demo\Abc_SpringBoot_Demo\target\spring-boot-demo-0.0.1-SNAPSHOT.jar
|
|
|
+ * 转换为
|
|
|
+ * \E:\Java\demo\Abc_SpringBoot_Demo\target\spring-boot-demo-0.0.1-SNAPSHOT.jar
|
|
|
+ */
|
|
|
+ if (filePath.contains("file:")) {
|
|
|
+ filePath = filePath.substring(filePath.indexOf("file:") + "file:".length());
|
|
|
}
|
|
|
File file = new File(filePath);
|
|
|
filePath = file.getAbsolutePath().replace("\\", "/");
|
|
|
@@ -41,6 +49,18 @@ public final class PathUtil {
|
|
|
if (file.isDirectory() && !filePath.endsWith("/")) {
|
|
|
filePath = filePath + "/";
|
|
|
}
|
|
|
+ // spring-boot jar包里的class, 获取到的形如: your-spring-boot.jar!/BOOT-INF/classes!
|
|
|
+ String springBootJarInnerClass = "!/BOOT-INF/classes!";
|
|
|
+ if (filePath.endsWith(springBootJarInnerClass)) {
|
|
|
+ filePath = filePath.substring(0, filePath.length() - springBootJarInnerClass.length());
|
|
|
+ }
|
|
|
+ // spring-boot jar包里jar包里的class, 获取到的形如: your-spring-boot.jar!/BOOT-INF/lib/your-lib-jar.jar!
|
|
|
+ String springBootJarInnerJar = "!/BOOT-INF/lib";
|
|
|
+ int idx = filePath.indexOf(springBootJarInnerJar);
|
|
|
+ if (idx >= 0) {
|
|
|
+ filePath = filePath.substring(0, idx);
|
|
|
+ }
|
|
|
+
|
|
|
return filePath;
|
|
|
}
|
|
|
}
|