FileSystemResource 和 ClassPathResource 有何区别

 

在FileSystemResource 中须要给出spring-config.xml文件在你项目中的相对路径或者绝对路径。在ClassPathResource中spring会在ClassPath中自动搜寻配置文件,因此要把ClassPathResource 文件放在ClassPath下。spring

若是将spring-config.xml保存在了src文件夹下的话,只需给出配置文件的名称便可,由于src文件夹是默认。spa

简而言之,ClassPathResource在环境变量中读取配置文件,FileSystemResource在配置文件中读取配置文件。xml

相关文章
相关标签/搜索