问题标签 [resource-loading]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
87 浏览

gradle - Java - 如何使用 gradle 和 Intelij 从源文件夹加载资源

我正在使用 Gradle 和 IntelliJ。我有一个具有以下结构的项目:

我想阅读 myfile.json,但没有办法让它工作。我已经知道我可以创建资源文件夹,使用资源文件夹可以正常工作。但这是一个遗留项目,我现在无法更改。

我正在使用以下内容加载资源

但我无法让它工作。我什至改变了我的配置 Intelij 就像这个Intelij Configuration

0 投票
0 回答
62 浏览

java - Spring Boot PathMatchingResourcePatternResolver 找不到预期的资源

尝试使用久经考验的方法获取资源时

(resourceLoader是spring boot默认提供的@Autowired)

当文件在 /BOOT-INF/classes/es/ 下的类路径中明显存在时,esResources 返回空

更大的谜团是代码在我们的一个单独的 repo 中运行,运行相同的 spring-boot 版本(spring-boot-starter-parent 2.4.5)。

通过调试器单步执行这两个存储库,我在此步骤中发现了一个差异PathMatchingResourcePatternResolver- 工作的一个正在使用TomcatEmbeddedWebappClassLoader,而“损坏”的一个正在显示ClassLoaders$AppClassLoader。不确定这是否是红鲱鱼。