소스 검색

优化class path获取

zhou-hao 6 년 전
부모
커밋
c95976a689
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/ModuleUtils.java

+ 6 - 0
hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/ModuleUtils.java

@@ -58,6 +58,12 @@ public abstract class ModuleUtils {
         }
         String path = codeSource.getLocation().toString();
 
+        boolean isJar = path.contains("!/") && path.contains(".jar");
+
+        if (isJar) {
+            return path.substring(0, path.lastIndexOf(".jar") + 4);
+        }
+
         if (path.endsWith("/")) {
             return path.substring(0, path.length() - 1);
         }