RickyTan
RickyTan

Reputation: 11

Spring Boot PathMatchingResourcePatternResolver not finding the expected Resources

When trying to fetch resources using the tried-and-true

Resource[] esResources = ResourcePatternUtils.getResourcePatternResolver(resourceLoader)
                .getResources("classpath*:/es/" + storageFilename + ".json")

(resourceLoader is the default @Autowired provided by spring boot)

esResources returns empty when the file is clearly there in the classpath under /BOOT-INF/classes/es/

Bigger mystery is that the code works in a separate repo of ours, running the same spring-boot version (spring-boot-starter-parent 2.4.5).

Stepping both repos through the debugger, I found a diff at this step within PathMatchingResourcePatternResolver-- the one that works is using TomcatEmbeddedWebappClassLoader, while the "broken" one is showing ClassLoaders$AppClassLoader. Not sure if this is a red herring though.

Upvotes: 1

Views: 669

Answers (0)

Related Questions