Skip to main content

Resource Abstraction: Resource, ResourceLoader, ResourcePatternResolver and Resource Injection

Learn Resource Abstraction: Resource, ResourceLoader, ResourcePatternResolver and Resource Injection (Phase 12 · Spring Resources and Utilities (Core), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

The Resource abstraction • org.springframework.core.io.Resource abstracts access to files, classpath entries, URLs, servlet context paths, byte arrays and input streams: exists() , isReadable() , getInputStream() , getFile() , getURL() , contentLength() . Implementations: ClassPathResource , FileSystemResource , UrlResource , ServletContextResource , ByteArrayResource , InputStreamResource , PathResource . • Location prefixes : classpath: , classpath*: (all matching entries on the classpath, including jars), file: , http: / https: ; no prefix → depends on the context.

More lessons in Phase 12 · Spring Resources and Utilities (Core)