xinrong2019 / xinrong2019.github.io

My Blog
https://xinrong2019.github.io
1 stars 1 forks source link

20190721 Spring Framework体系化学习之Resources #94

Open xinrong2019 opened 5 years ago

xinrong2019 commented 5 years ago

注意有哪些接口?

注意通配符的使用?怎么用?

2.3. Built-in Resource Implementations

2.4. The ResourceLoader

2.5. The ResourceLoaderAware interface

2.6. Resources as Dependencies

2.7. Application Contexts and Resource Paths

2.7.1. Constructing Application Contexts

2.7.2. Wildcards in Application Context Constructor Resource Paths

应用程序上下文构造函数值中的资源路径可以是简单路径(如前所示),每个路径都与目标资源进行一对一映射,或者可以包含特殊的“classpath *:”前缀或内部Ant式正则表达式(使用Spring的PathMatcher实用程序进行匹配)。后者都是有效的通配符。

Ant-style Patterns

/WEB-INF/*-context.xml
com/mycompany/**/applicationContext.xml
file:C:/some/path/*-context.xml
classpath:com/mycompany/**/applicationContext.xml

Implications on Portability(对可移植的影响)

The classpath*: Prefix

此特殊前缀指定必须获取与给定名称匹配的所有类路径资源(在内部,这主要通过调用ClassLoader.getResources(...))然后合并以形成最终的应用程序上下文定义。