spring路径(个人笔记)

Spring支持的资源类型地址前缀

  1. classpath:  ,从类路径装载资源,和classpath:/ 等价

    classpath:com/examples/beans.xml

  2. file: ,从文件系统目录中装载资源,可使用绝对或相对路径

    file:conf/com/examples/beans.xml

  3. http:// ,从WEB服务器中装载资源

    http://www.examples.com/resource/beans.xml

  4. ftp:// ,从FTP服务器中装载资源

    ftp://www.examples.com/resource/beans.xml

  5. 没有前缀,根据ApplicationContext具体实现采用相应的Resource

Ant模式通配符匹配, 支持“?”、“*”、“**”,注意通配符匹配不包括目录分隔符“/”

  ?   匹配一个字符

  *    匹配任意数量的字符

  **   匹配任意数量的字符

  com/*/config.xml  可匹配com/examples/config.xml等,不能匹配com/config.xml

  com/**/config.xml 可匹配 com/examples/config.xml等,也可匹配com/config.xml

  **有时候可作*, com/*.xml 和com/**.xml相同

classpath: 与 classpath*:

classpath:  装载路径下的第一个资源

classpath*: 装载路径下多有的资源

原文地址:https://www.cnblogs.com/gxl00/p/4775464.html