spring源码---BeanDefinition

分为三个步骤:resource文件定位、加载、注册。IOC容器其实就是一个map,concurrentHashMap

加载过程中,默认会读取xml文件中前缀是classpath的文件路径。呈上代码:

StringCLASSPATH_ALL_URL_PREFIX ="classpath*:";

public Resource[] getResources(String locationPattern)throws IOException {

Assert.notNull(locationPattern,"Location pattern must not be null");

if (locationPattern.startsWith(CLASSPATH_ALL_URL_PREFIX)) {

// a class path resource (multiple resources for same name possible)

      if (getPathMatcher().isPattern(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()))) {

// a class path resource pattern

        return findPathMatchingResources(locationPattern);

}

else {

// all class path resources with the given name

        return findAllClassPathResources(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()));

}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容