java - Java ClassLoader getResources 不适用于 Launcher$AppClassLoader
问题描述
此代码片段在被 websphere 服务器调用时工作正常(cl 的类型为 com.ibm.ws.classloader.CompoundClassLoader)。
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Enumeration resenum = cl.getResources("/abc.xml");
但是,当我从 main 方法在独立类中运行相同的代码时(通过将 abc.xml 的文件夹路径添加到运行时配置), resnum 为空。cl 是 sun.misc.Launcher$AppClassLoader 类型。如果我从代码中删除“/”,它工作正常。有没有办法可以在 abc.xml 之前加载一个“/”(可能使用其他一些类加载器)?请帮忙。
解决方案
推荐阅读
- wpf - 如何将 asp.net mvc5 项目与 wpf 项目一起加入
- azure - 使用社交登录进行身份验证后,Azure AD B2C 跳过登录页面
- java - 带有 IN 子句的 PreparedStatement
- java - 多模块项目构建期间模块之间的 Maven 依赖关系解析
- azure - org.apache.spark.sql.AnalysisException:尝试从 spark 访问 azure 时路径不存在
- c++ - 编写特定的 Clang 检查
- x86 - 如何使用 perf 正确测量 IPC(每周期指令)
- css - 使用 divi 的网站 - wordpress 在谷歌浏览器上工作,但没有 safari
- javascript - RxJS distinctUntilChanged 多次发出相同的值
- python - 当特征值重复时,MATLAB/numpy 会显示哪些特征向量