【fix sonar】MyClassLoader文件

This commit is contained in:
梁琦涛
2023-03-08 12:02:27 +08:00
parent 74d09a897a
commit 6d3129afea
@@ -1,5 +1,7 @@
package com.jero.common.util;
import com.jero.common.exception.JeroBootException;
/**
* @Author 张代浩
*/
@@ -10,7 +12,7 @@ public class MyClassLoader extends ClassLoader {
myclass = Class.forName(className);
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(className+" not found!");
throw new JeroBootException(className+" not found!");
}
return myclass;
}
@@ -76,16 +78,16 @@ public class MyClassLoader extends ClassLoader {
if (realPath.endsWith("!")) {
realPath = realPath.substring(0, realPath.lastIndexOf("/"));
}
/*------------------------------------------------------------
ClassLoader的getResource方法使用了utf-8对路径信息进行了编码,当路径
中存在中文和空格时,他会对这些字符进行转换,这样,得到的往往不是我们想要
的真实路径,在此,调用了URLDecoder的decode方法进行解码,以便得到原始的
中文及空格路径
/*------------------------------------------------------------
ClassLoader的getResource方法使用了utf-8对路径信息进行了编码,当路径
中存在中文和空格时,他会对这些字符进行转换,这样,得到的往往不是我们想要
的真实路径,在此,调用了URLDecoder的decode方法进行解码,以便得到原始的
中文及空格路径
-------------------------------------------------------------*/
try {
realPath = java.net.URLDecoder.decode(realPath, "utf-8");
} catch (Exception e) {
throw new RuntimeException(e);
throw new JeroBootException(e);
}
return realPath;
}// getAppPath定义结束