类ClassPathResource及其构造方法

文档地址 https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/ClassPathResource.html
Package org.springframework.core.io

Class ClassPathResource

java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.core.io.AbstractFileResolvingResource
org.springframework.core.io.ClassPathResource
All Implemented Interfaces: InputStreamSource, Resource

public class ClassPathResource extends AbstractFileResolvingResource

类路径资源的资源实现。使用指定的 ClassLoader 或指定的 Class 加载资源。
Resource implementation for class path resources. Uses either a given ClassLoader or a given Class for loading resources.

如果类路径资源位于文件系统中,则支持解析为 java.io.File,但 JAR 中的资源则不支持。始终支持解析为 java.net.URL。
Supports resolution as java.io.File if the class path resource resides in the file system, but not for resources in a JAR. Always supports resolution as java.net.URL.

ClassPathResource(String path)

Constructor
ClassPathResource(String path)

Description
Create a new ClassPathResource for ClassLoader usage.

posted @ 2025-04-13 19:03  kuki'  阅读(32)  评论(0)    收藏  举报